Commits

Vladimir Kolev committed 3fbff3a

Fixed problems with grooveshark and the new design now gSharkDown works

Comments (0)

Files changed (2)

     p["method"] = "getCommunicationToken"
     p["header"] = h
     p["header"]["client"] = "htmlshark"
-    p["header"]["clientRevision"] = "20110606"
+    p["header"]["clientRevision"] = "20110906"
     conn = httplib.HTTPSConnection("grooveshark.com")
     conn.request("POST", "/more.php",
                  json.JSONEncoder().encode(p),
     _token = json.JSONDecoder().decode(gzipfile.read())["result"]
 
 
-def getSearchResultsEx(query, type = "Songs"):
+def getSearchResultsEx(query, _type = "Songs"):
     """
     Method to get the search results from the gs service
     and returns them as dictionary.
     """
     p = {}
     p["parameters"] = {}
-    p["parameters"]["type"] = type
+    p["parameters"]["type"] = _type
     p["parameters"]["query"] = query
     p["header"] = h
     p["header"]["client"] = "htmlshark"
     p["header"]["clientRevision"] = "20110906"
-    p["header"]["token"] = prepToken("getSearchResultsEx", ":backToTheScienceLab:")
-    p["method"] = "getSearchResultsEx"
+    p["header"]["token"] = prepToken("getResultsFromSearch", ":imOnAHorse:")
+    p["method"] = "getResultsFromSearch"
     conn = httplib.HTTPConnection("grooveshark.com")
     conn.request("POST", "/more.php?" + p["method"],
                  json.JSONEncoder().encode(p),
         return j['result']['result']
 
 
-def getStreamKeyFromSongIDEx(id):
+def getStreamKeyFromSongIDEx(_id):
     """
     Gets the stream URL for Song ID
     """
     p["parameters"] = {}
     p["parameters"]["mobile"] = "false"
     p["parameters"]["prefetch"] = "false"
-    p["parameters"]["songIDs"] = id
+    p["parameters"]["songIDs"] = _id
     p["parameters"]["country"] = h["country"]
     p["header"] = h
     p["header"]["client"] = "jsqueue"
-    p["header"]["clientRevision"] = "20110606.04"
-    p["header"]["token"] = prepToken("getStreamKeysFromSongIDs", ":bewareOfBearsharktopus:")
+    p["header"]["clientRevision"] = "20110906"
+    p["header"]["token"] = prepToken("getStreamKeysFromSongIDs", ":theTicketsAreNowDiamonds:")
     p["method"] = "getStreamKeysFromSongIDs"
     conn = httplib.HTTPConnection("grooveshark.com")
     conn.request("POST", "/more.php?" + p["method"],
                     time.sleep(1)
                 else:
                     error = guihelpers.ErrorMessage(None,
-                                    "grooveshark service has changed!\n" +
+                                    "grooveshark service has probably changed!\n" +
                                     "gSharkDown will not function propperly, so please" +
                                     "be patient till we find a sallution")
                     error.show_all()
         self.win.entry.set_sensitive(False)
         try:
             results = groove.getSearchResultsEx(self.term, self.type)
-        except Exception, e:
-            print e.args
-        self.win.entry.set_sensitive(True)
-        self.win.result.clear()
-        for item in results:
-            self.win.result.append([item['SongName'],
+            self.win.entry.set_sensitive(True)
+            self.win.result.clear()
+            if results:
+                for item in results:
+                    self.win.result.append([item['SongName'],
                                     item['ArtistName'],
                                     item['AlbumName'],
                                     item['SongID'],
                                     item])
+        except Exception, e:
+            print e.args
 
 
 class UpdateThread(threading.Thread):