Commits

Damián Nohales committed 87e74fa Merge

Merge vkolev changes

Comments (0)

Files changed (4)

         """
         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,

lib/guihelpers.py

         @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"))
         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
                     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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.