Commits

Damián Nohales committed f56eebd

Better streaming error handle.

Comments (0)

Files changed (3)

             "audio-x-generic")
         self.pynotify_object.show()
     
-    def on_playing_error(self):
-        guihelpers.ErrorMessage(self.window, _("An error has occurred while playing the song. Please try again later."))
-        self.set_playing_song(None)
-    
     def play_first_song(self):
         if len(self.playlist) > 0:
             self.set_playing_song(self.playlist.get_song(0))
     
     gzipfile = gzip.GzipFile(fileobj = (StringIO.StringIO(resp)))
     j = json.JSONDecoder().decode(gzipfile.read())
+    
+    if len(j["result"][_id]) == 0:
+        raise Exception("The song streaming key is empty")
+    
     return j
 
 
         
         try:
             play_url = self.song.get_streaming_url()
-        except Exception, e:
+        except Exception as e:
             traceback.print_exc(file=sys.stdout)
-            gobject.idle_add(self.app.on_playing_error)
+            gobject.idle_add(self.on_playing_error, e.__str__())
             return
         
         if self.stopped():
 
     def stopped(self):
         return self._stop.isSet()
+    
+    def on_playing_error(self, error):
+        guihelpers.ErrorMessage(self.app.window, _("An error occurred while playing the song. Please try again later.\n\nThe error was: %s") % error)
+        self.app.set_playing_song(None)
 
 
 class KeyListenerThread(threading.Thread):