1. Vladimir Kolev
  2. gSharkDown

Commits

Vladimir Kolev  committed 828a35f

Lyrics now get the correct playing song, and the Error dialog is modal again.

The error dialog still causes the application to crash ...

  • Participants
  • Parent commits 9dc8aed
  • Branches default

Comments (0)

Files changed (4)

File lib/SharkDown.py

View file
         """
         Tries to retrieve lyrics for selected song from the playlist.
         """
-        if self.current_song != None:
-            t = LyricsThread(self, self.current_song)
+        if self.playlist.playing_song != None:
+            t = LyricsThread(self, self.playlist.playing_song)
             t.start()
         else:
             info = guihelpers.InfoDialog(self.window,

File lib/guihelpers.py

View file
         @param message : The error message to be shown
         """
         gtk.MessageDialog.__init__(self, parent,
-                            gtk.DIALOG_DESTROY_WITH_PARENT,
+                            gtk.DIALOG_MODAL,
                             gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
         self.set_default_response(gtk.RESPONSE_OK)
         self.set_title(_("Error"))

File lib/lyrdblib.py

View file
         query = artist.replace(" ", "+")
         query += "+"
         query += track.replace(" ", "+")
-
-    req = urllib2.urlopen(LOOKUP_URL % (query, method))
-    result = req.read()
-    resp = ""
-    if "error" in result:
+    try:
+        req = urllib2.urlopen(LOOKUP_URL % (query, method))
+        result = req.read()
+        resp = ""
+        if "error" in result:
+            resp = "error"
+        elif result == "":
+            resp = "error"
+        else:
+            t = result.splitlines()
+            resp = t[0].split("\\")[0]
+    except:
         resp = "error"
-    elif result == "":
-        resp = "error"
-    else:
-        t = result.splitlines()
-        resp = t[0].split("\\")[0]
     return resp
 
 def searchchart(artist, track):
     """
     artist = artist.replace(" ", "%20")
     track = track.replace(" ", "%20")
-
-    req = urllib2.urlopen(CHART_URL % (artist, track))
-    result = req.read()
-    resp = ""
-    if "<LyricChecksum>" in result:
-        lyric = ElementTree.fromstring(result)
-        lyr = lyric.getchildren()[len(lyric.getchildren()) - 1]
-        resp = lyr.text
-    else:
+    try:
+        req = urllib2.urlopen(CHART_URL % (artist, track))
+        result = req.read()
+        resp = ""
+        if "<LyricChecksum>" in result:
+            lyric = ElementTree.fromstring(result)
+            lyr = lyric.getchildren()[len(lyric.getchildren()) - 1]
+            resp = lyr.text
+        else:
+            resp = "error"
+    except:
         resp = "error"
     return resp

File lib/tfuncs.py

View file
                     self.app.result.append_song(Song(song_data))
         except Exception, e:
             print e.args
+        
+        self.__stop()
 
 
 class UpdateThread(threading.Thread):
         if "ERROR:" in lyrics:
             error = guihelpers.ErrorMessage(None,
                 lyrics)
-            error.show_all()
+            error.run()
         else:
             lyrdiag = guihelpers.LyricsDialog(self.song, lyrics)
             lyrdiag.show_all()