sigma67 / spotify_to_ytmusic

Clone a Spotify playlist to YouTube Music
MIT License
954 stars 72 forks source link

Could not transfer playlist test. Exception'videoId' #46

Closed simonepignotti closed 1 year ago

simonepignotti commented 1 year ago

Hi, I encounter the following error when running the YouTube.py script:

4 playlists found. Starting transfer...
Playlist 1: test
Spotify tracks: 5/5
Could not transfer playlist WLG. Exception'videoId'
[...]

Removing the try/except I get a better help message:

4 playlists found. Starting transfer...
Playlist 1: test
Spotify tracks: 5/5
Traceback (most recent call last):
  File "/Volumes/datvol/Perso/spym/spotifyplaylist_to_ytmusic/YouTube.py", line 190, in <module>
    main()
  File "/Volumes/datvol/Perso/spym/spotifyplaylist_to_ytmusic/YouTube.py", line 150, in main
    videoIds = ytmusic.search_songs(playlist['tracks'])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/datvol/Perso/spym/spotifyplaylist_to_ytmusic/YouTube.py", line 74, in search_songs
    targetSong = self.get_best_fit_song_id(result, song)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/datvol/Perso/spym/spotifyplaylist_to_ytmusic/YouTube.py", line 43, in get_best_fit_song_id
    title_score[res['videoId']] = difflib.SequenceMatcher(a=title.lower(), b=song['name'].lower()).ratio()
                ~~~^^^^^^^^^^^
KeyError: 'videoId'

And this is what I get when I print req:

{'resultType': 'song', 'title': 'Avant Gardener', 'artists': [{'name': 'Courtney Barnett', 'id': 'UCAR6fZVOSmnctDecWdS9rtQ'}], 'album': {'name': 'The Double EP: A Sea of Split Peas', 'id': 'MPREb_T088NuxNhsq'}, 'duration': '5:13', 'duration_seconds': 313, 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/D3R44aaDMdBbV5QZCk_qjizA-teEO2GtYDY62NjP1-fRVDhyk7Qh1AxFA5AOxMuk3GSM0Chpqg5Jicy4=w60-h60-l90-rj', 'width': 60, 'height': 60}, {'url': 'https://lh3.googleusercontent.com/D3R44aaDMdBbV5QZCk_qjizA-teEO2GtYDY62NjP1-fRVDhyk7Qh1AxFA5AOxMuk3GSM0Chpqg5Jicy4=w120-h120-l90-rj', 'width': 120, 'height': 120}]}

Hope that helps! Thanks for developing and maintaining this repo.

sigma67 commented 1 year ago

Hi Simone, please update your version of ytmusicapi to 0.25.2, that should fix it

simonepignotti commented 1 year ago

Thanks a lot for the quick fix 👍