Commits

Vladimir Kolev committed 878b7ef

Fixed the bad issue #4 and made the application to check for updates on start

  • Participants
  • Parent commits 9f545b7

Comments (0)

Files changed (6)

-0.2.9
+0.2.9-1

File data/about_dialog.ui

     <property name="icon">gsharkdown_64.png</property>
     <property name="type_hint">dialog</property>
     <property name="program_name">gSharkDown</property>
-    <property name="version">0.2.9</property>
+    <property name="version">0.2.9-1</property>
     <property name="copyright" translatable="yes">(c) Vladimir Kolev 2011</property>
     <property name="comments" translatable="yes">Gnome-toolkit based desktop application for downloading music files from Grooveshark.com</property>
     <property name="website">https://bitbucket.org/vkolev/gsharkdown</property>

File data/gsharkdown.ini

-down_path = 
+down_path = ""
 show_stat_icon = 0
-repeat_playlist = 1
+repeat_playlist = 0
 shuffle_playlist = 0
 show_notification = 0
+update_checked = 1
 completition = Roni Size|Eminem|Madonna|Skillet|DMX|Dr. Dre|Ceca|Ceca Velickovic|Syrenia|Within temptation|Lady Gaga|EMinem|Beatles|Scorpions|Deep Purple|Na Inat|Foureira|

File gsharkdown.py

         builder.connect_signals(self)
         self.tlisten = t_key_listener(self)
         self.tlisten.start()
+        self.check_for_update(None)
         self.window.show_all()
 
     def load_saved_playlist(self):
         remote = urllib2.urlopen(checkurl)
         remoteversion = remote.read().replace("\n", "")
         if remoteversion > localversion:
+            CONFIG['update_checked'] = 0
+            CONFIG.write()
             upddiag = gtk.MessageDialog(None,
                                        gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_INFO)
                 downurl = "http://bitbucket.org/vkolev/gsharkdown/downloads"
                 webbrowser.open(downurl)
             upddiag.destroy()
+        else:
+            if int(CONFIG['update_checked']) == 1:
+                pass
+            else:
+                upddiag = gtk.MessageDialog(None,
+                                       gtk.DIALOG_DESTROY_WITH_PARENT,
+                                       gtk.MESSAGE_INFO)
+                upddiag.set_title("No updates")
+                othertext = "Congratulations!\n"
+                markup = "<b>You are using the latest version!</b>"
+                upddiag.set_markup(markup)
+                upddiag.format_secondary_text(othertext)
+                upddiag.add_buttons(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL,
+                               gtk.STOCK_OK, gtk.RESPONSE_OK)
+                CONFIG['update_checked'] = 1
+                CONFIG.write()
+                upddiag.run()
+                upddiag.destroy()
 
     def icon_clicked(self, widget, data=None):
         """

File lib/groove.py

 
 _useragent = \
 """Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"""
-_referer = "http://grooveshark.com/JSQueue.swf?20110216.04"
+_referer = "http://grooveshark.com/JSQueue.swf?20110725.01"
 _token = None
 
 h = {}
-h["Country"] = {}
-h["Country"]["CC1"] = "0"
-h["Country"]["CC2"] = "0"
-h["Country"]["CC3"] = "0"
-h["Country"]["CC4"] = "0"
-h["Country"]["ID"] = "1"
+h["country"] = {}
+h["country"]["CC1"] = "0"
+h["country"]["CC2"] = "0"
+h["country"]["CC3"] = "0"
+h["country"]["CC4"] = "0"
+h["country"]["ID"] = "1"
 h["privacy"] = 0
 h["session"] = None
-h["uuid"] = str(uuid.uuid4())
+h["uuid"] = str.upper(str(uuid.uuid4()))
 
 entrystring = \
 """A Grooveshark song downloader in python
 """
 
 
-def prepToken(method):
+def prepToken(method, sectoken):
     rnd = (''.join(random.choice(string.hexdigits) for x in range(6))).lower()
     hashs = hashlib.sha1(
-        method + ":" + _token + ":quitStealinMahShit:" + rnd).hexdigest()
+        method + ":" + _token + sectoken + rnd).hexdigest()
     ret = rnd + hashs
     return ret
 
     p["method"] = "getCommunicationToken"
     p["header"] = h
     p["header"]["client"] = "htmlshark"
-    p["header"]["clientRevision"] = "20101222.35"
+    p["header"]["clientRevision"] = "20110606"
     conn = httplib.HTTPSConnection("grooveshark.com")
     conn.request("POST", "/more.php",
                  json.JSONEncoder().encode(p),
     p["parameters"]["query"] = query
     p["header"] = h
     p["header"]["client"] = "htmlshark"
-    p["header"]["clientRevision"] = "20101222"
-    p["header"]["token"] = prepToken("getSearchResultsEx")
+    p["header"]["clientRevision"] = "20110606"
+    p["header"]["token"] = prepToken("getSearchResultsEx", ":backToTheScienceLab:")
     p["method"] = "getSearchResultsEx"
     conn = httplib.HTTPConnection("grooveshark.com")
     conn.request("POST", "/more.php?" + p["method"],
                  json.JSONEncoder().encode(p),
                  {"User-Agent": _useragent,
                   "Referer": "http://grooveshark.com/",
-                  "Content-Type": "",
+                  "Content-Type": "application/json",
                   "Accept-Encoding": "gzip",
                   "Cookie": "PHPSESSID=" + h["session"]})
     resp = conn.getresponse().read()
     p["parameters"] = {}
     p["parameters"]["mobile"] = "false"
     p["parameters"]["prefetch"] = "false"
-    p["parameters"]["songID"] = id
-    p["parameters"]["country"] = h["Country"]
+    p["parameters"]["songIDs"] = id
+    p["parameters"]["country"] = h["country"]
     p["header"] = h
     p["header"]["client"] = "jsqueue"
-    p["header"]["clientRevision"] = "20101012.37"
-    p["header"]["token"] = prepToken("getStreamKeyFromSongIDEx")
-    p["method"] = "getStreamKeyFromSongIDEx"
+    p["header"]["clientRevision"] = "20110606.04"
+    p["header"]["token"] = prepToken("getStreamKeysFromSongIDs", ":bewareOfBearsharktopus:")
+    p["method"] = "getStreamKeysFromSongIDs"
     conn = httplib.HTTPConnection("grooveshark.com")
     conn.request("POST", "/more.php?" + p["method"],
                  json.JSONEncoder().encode(p),
                   "Cookie": "PHPSESSID=" + h["session"]})
     resp = conn.getresponse().read()
     gzipfile = gzip.GzipFile(fileobj=(StringIO.StringIO(resp)))
-    return json.JSONDecoder().decode(gzipfile.read())
+    j = json.JSONDecoder().decode(gzipfile.read())
+    print j
+    return j
 
 
 def header_cb(buf):

File lib/tfuncs.py

         try:
             key = groove.getStreamKeyFromSongIDEx(self.songid)
         except Exception, e:
-            self.win.show_error(e.args)
+            print e
         try:
             self.t = time.time()
             self.beg = self.t
             self.lastCount = 0
-            urlretrieve("http://" + key["result"]["ip"] + "/stream.php",
+            urlretrieve("http://" + key["result"]["%s" % self.songid]["ip"] + "/stream.php",
                        os.path.join(self.path, self.filename),
                        self.hook,
-                       "streamKey=" + key["result"]["streamKey"])
+                        "streamKey=" + key["result"]["%s" % self.songid]["streamKey"])
         except Exception, e:
             print e.args
 
         try:
             key = groove.getStreamKeyFromSongIDEx(self.songid)
         except Exception, e:
-            self.win.show_error(e.args)
+            print e
         playurls = "http://%s/stream.php?streamKey=%s"
-        play_url = playurls % (key["result"]["ip"], key["result"]["streamKey"])
+        play_url = playurls % (key["result"]["%s" % self.songid]["ip"],
+                               key["result"]["%s" % self.songid]["streamKey"])
         self.win.player.set_property('uri', play_url)
         self.win.player.set_state(gst.STATE_PLAYING)
         bus = self.win.player.get_bus()
         try:
             self.win.results = groove.getSearchResultsEx(self.term, self.type)
         except Exception, e:
-            self.win.show_error(e.args)            
+            print e.args
         for item in self.win.results:
             self.win.result.append([item['SongName'],
                                     item['ArtistName'],