#!/usr/bin/env python3
"""
Debug script to identify the tuple error.
"""

import sys
import os
sys.path.append('/app/src')

# Add the src directory to Python path
sys.path.insert(0, '/app/src')

from cli.main import MusicBrainzCleaner

def debug_test():
    """Test the cleaner step by step to find the tuple error."""
    print("🔍 Debugging MusicBrainz Cleaner...")
    
    # Initialize cleaner
    cleaner = MusicBrainzCleaner(use_database=True)
    
    # Test with a simple song
    test_song = {
        'artist': 'AC/DC',
        'title': 'Shot In The Dark'
    }
    
    print(f"Testing with: {test_song}")
    
    try:
        # Test _clean_artist_name
        print("1. Testing _clean_artist_name...")
        clean_artist = cleaner._clean_artist_name(test_song['artist'])
        print(f"   Clean artist: {clean_artist} (type: {type(clean_artist)})")
        
        # Test find_artist_mbid
        print("2. Testing find_artist_mbid...")
        artist_mbid = cleaner.find_artist_mbid(test_song['artist'])
        print(f"   Artist MBID: {artist_mbid} (type: {type(artist_mbid)})")
        
        if artist_mbid:
            # Test get_artist_info
            print("3. Testing get_artist_info...")
            artist_info = cleaner.get_artist_info(artist_mbid)
            print(f"   Artist info: {artist_info} (type: {type(artist_info)})")
            
            # Test find_recording_mbid
            print("4. Testing find_recording_mbid...")
            recording_mbid = cleaner.find_recording_mbid(artist_mbid, test_song['title'])
            print(f"   Recording MBID: {recording_mbid} (type: {type(recording_mbid)})")
            
            if recording_mbid:
                # Test get_recording_info
                print("5. Testing get_recording_info...")
                recording_info = cleaner.get_recording_info(recording_mbid)
                print(f"   Recording info: {recording_info} (type: {type(recording_info)})")
        
    except Exception as e:
        print(f"❌ Error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    debug_test() 