[grooveshark] catch exception when id is not an integer

This commit is contained in:
Bezleputh 2014-06-19 17:59:51 +02:00
commit 079bab9710

View file

@ -116,11 +116,14 @@ class GroovesharkBrowser(BaseBrowser):
def get_audio_from_song_id(self, _id): def get_audio_from_song_id(self, _id):
audio = GroovesharkAudio(_id) audio = GroovesharkAudio(_id)
audio.url = self.get_stream_url_from_song_id(_id) audio.url = self.get_stream_url_from_song_id(_id)
if audio.url is not None:
return audio return audio
else:
return None
def get_stream_url_from_song_id(self, _id): def get_stream_url_from_song_id(self, _id):
method = 'getStreamKeyFromSongIDEx' method = 'getStreamKeyFromSongIDEx'
try:
parameters = {} parameters = {}
parameters['prefetch'] = False parameters['prefetch'] = False
parameters['mobile'] = True parameters['mobile'] = True
@ -132,6 +135,8 @@ class GroovesharkBrowser(BaseBrowser):
self.mark_song_downloaded_ex(response['result']) self.mark_song_downloaded_ex(response['result'])
return u'http://%s/stream.php?streamKey=%s' % (response['result']['ip'], response['result']['streamKey']) return u'http://%s/stream.php?streamKey=%s' % (response['result']['ip'], response['result']['streamKey'])
except ValueError:
return
def search_albums(self, pattern): def search_albums(self, pattern):
method = 'getResultsFromSearch' method = 'getResultsFromSearch'