Author: duncan
Date: Fri Jul 27 14:27:37 2007
New Revision: 9765

Log:
[ 1760242 ] audio scrobbler for last.fm
Threading patch from Wout Clymans applied


Modified:
   branches/rel-1/freevo/src/audio/audioitem.py

Modified: branches/rel-1/freevo/src/audio/audioitem.py
==============================================================================
--- branches/rel-1/freevo/src/audio/audioitem.py        (original)
+++ branches/rel-1/freevo/src/audio/audioitem.py        Fri Jul 27 14:27:37 2007
@@ -44,6 +44,7 @@
 try:
     if config.LASTFM_SCROBBLE:
         from plugins.freevo_scrobbler import Scrobbler
+        import thread
         SCROBBLE = True
     else:
         SCROBBLE = False
@@ -179,19 +180,28 @@
 
         #last.fm scrobbler
         if SCROBBLE:
-            scrobbler = Scrobbler()
-            if scrobbler.send_handshake():
-                scrobbler.submit_song(self.info)
+            self.scrobbled = False
+            thread.start_new_thread(self.scrobble_song,())
 
         if error and menuw:
             AlertBox(text=error).show()
             rc.post_event(rc.PLAY_END)
 
+    def scrobble_song(self):
+        """ Scrobble the song """
+        while True and not self.scrobbled and self.player.player.is_playing():
+            if self.elapsed > self.info['length'] / 2:
+                scrobbler = Scrobbler()
+                if scrobbler.send_handshake():
+                    scrobbler.submit_song(self.info)
+                self.scrobbled = True
+            time.sleep(1)
 
     def stop(self, arg=None, menuw=None):
         """
         Stop the current playing
         """
+        if SCROBBLE: self.scrobbled = True
         self.player.stop()
 
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to