Commits

Anonymous committed 6444c21

Version change: 0.2.5
New features:
Saving the playlist on exit
Notification on song change
New dependences:
pickle - for saving the playlist
Fixed bugs:
Default download path is now estimated when empty
$HOME + /Music

Comments (0)

Files changed (5)

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.2</property>
+    <property name="version">0.2.5</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>

data/gsharkdown.ini

-down_path = /home/vladi/Desktop
+down_path = 
 show_stat_icon = 0
 repeat_playlist = 1
 shuffle_playlist = 0
-completition = Roni Size|Eminem|Madonna|Skillet|DMX|Dr. Dre|Ceca|Ceca Velickovic|Syrenia|Within temptation|Lady Gaga|EMinem|Beatles|Scorpions|Deep Purple|Na Inat|
+show_notification = 0
+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|

Empty file added.

data/preferenes_dialog.ui

           </packing>
         </child>
         <child>
+          <object class="GtkHBox" id="hbox3">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkCheckButton" id="checkbutton2">
+                <property name="label" translatable="yes">Show notifications on track change</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="padding">15</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">1</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkHSeparator" id="hseparator1">
             <property name="visible">True</property>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="position">2</property>
+            <property name="position">3</property>
           </packing>
         </child>
         <child>
           <packing>
             <property name="expand">False</property>
             <property name="padding">5</property>
-            <property name="position">3</property>
+            <property name="position">4</property>
           </packing>
         </child>
       </object>
 from lib.tfuncs import t_search
 import urllib2
 import webbrowser
+import pickle
 
 try:
     import pygtk
     sys.exit(1)
 
 try:
+    import pynotify
+except ImportError:
+    print "You don't have pynotify installed!"
+    sys.exit(1)
+
+try:
     import pygst
     pygst.require('0.10')
     import gst
         self.staticon.connect("activate", self.icon_clicked)
         self.staticon.set_tooltip("gSharkDown : Download from Grooveshark")
 
+        if os.path.exists("%s/data/playlist.pkl" % BASEPATH):
+            self.load_saved_playlist()
+        else:
+            print "Playlist not found"
+
+        if int(CONFIG['show_notification']) == 1:
+            pynotify.init("gSharkDown")
+
         builder.connect_signals(self)
 
         self.window.show_all()
 
+    def load_saved_playlist(self):
+        file = open("%s/data/playlist.pkl" % BASEPATH, 'rb')
+        eoferror = True
+        while eoferror:
+            try:
+                self.playitems.append(pickle.load(file))
+            except:
+                eoferror = False
+        
+        for i in range(0, len(self.playitems)):
+            self.playlist.append([
+                self.playitems[i]['SongName'],
+                self.playitems[i]['ArtistName'],
+                self.playitems[i]['SongID']
+                ])
+
+
     def window_close(self, widget, data=None):
         """
         How to act on closing the window
         dialog.set_title("Quit?")
         response = dialog.run()
         if response == gtk.RESPONSE_YES:
+            try:
+                output = open("%s/data/playlist.pkl" % BASEPATH, 'w')
+                for i in range(0, len(self.playitems)):
+                    pickle.dump(self.playitems[i], output)
+                output.close()
+            except:
+                print "Error saving the playlist"
             gtk.main_quit()
         dialog.destroy()
 
         builder.add_from_file('%s/data/preferenes_dialog.ui' % BASEPATH)
         prefs = builder.get_object('window1')
         self.dest = builder.get_object('entry1')
-        self.dest.set_text(CONFIG['down_path'])
+        if CONFIG['down_path'] == "":
+            self.dest.set_text(os.environ.get('HOME')+"/Music")
+        else:
+            self.dest.set_text(CONFIG['down_path'])
         self.notify = builder.get_object("checkbutton1")
         self.notify.set_active(int(CONFIG['show_stat_icon']))
+        self.bubble = builder.get_object("checkbutton2")
+        self.bubble.set_active(int(CONFIG['show_notification']))
         builder.connect_signals(self)
         prefs.show_all()
 
             CONFIG['show_stat_icon'] = 1
         else:
             CONFIG['show_stat_icon'] = 0
+        
+        if self.bubble.get_active():
+            CONFIG['show_notification'] = 1
+        else:
+            CONFIG['show_notification'] = 0
         CONFIG.write()
         win = widget.get_window()
         win.destroy()
                 "<b>Playing:</b> %s - %s" % (song['ArtistName'],
                                          song['SongName'])
             )
+            if int(CONFIG['show_notification']) == 1:
+                n = pynotify.Notification("Now playing",
+                    "%s - %s" % (song['ArtistName'], song['SongName']),
+                    "audio-x-generic")
+                n.show()
         else:
             self.staticon.set_from_file("%s/data/gsharkdown_16.png" % BASEPATH)
             self.staticon.set_tooltip(
             song = self.results[index]
             filename = "%s - %s.mp3" % (song["ArtistName"].strip("<>:\"/\|?*"),
                                     song["SongName"].strip("<>:\"/\|?*"))
+            if CONFIG['down_path'] == "":
+                CONFIG['down_path'] = os.environ.get("HOME") + "/Music"
             t = t_download(self, song, filename, CONFIG['down_path'])
             t.start()
         else:
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.