suyashb95 / soundcloud-dl

A Python project that downloads tracks from soundcloud.com, complete with metadata and album art
125 stars 20 forks source link

Error when genre is not set for track #9

Closed erwinelling closed 7 years ago

erwinelling commented 7 years ago

Ran into this error:

Connecting ... 
Single playlist found.
2 tracks found in this playlist
Traceback (most recent call last):
  File "download.py", line 8, in <module>
    downloaderObject.Download()
  File "/Users/erwinelling/.virtualenvs/verhalen/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 355, in Download
    self.getPlaylists(data)
  File "/Users/erwinelling/.virtualenvs/verhalen/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 109, in getPlaylists
    self.getSingleTrack(track)
  File "/Users/erwinelling/.virtualenvs/verhalen/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 71, in getSingleTrack
    'genre':track['genre'].encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'

Think it might be that there is not genre set for this track. It might be fixed by changing line 71 in downloader/downloader.py from:

            'genre':track['genre'].encode('utf-8')

to:

            'genre':track.get('genre','').encode('utf-8')

But I don't know for sure and am note sure of how to change it and do a pull request.

suyashb95 commented 7 years ago

Thanks for pointing that out, I think the change you've suggested is the way to go. Could you send me the URL of that particular playlist so I can test it?

erwinelling commented 7 years ago

Yes, this is my test playlist: https://soundcloud.com/user-787148065/sets/misc

suyashb95 commented 7 years ago

Thank you, fixed here. Turns out dict.get() didn't work since the track's dictionary has genre as None when it's unknown.