Re: [Rhythmbox-devel] First impression of LastRhythm



On Sat, 2007-02-10 at 16:50 +0100, Lars Strojny wrote: 
> I just want to inform you about LastRhythm, a Rhythmbox-plugin for music
> recommendations similar to the recommendations-plugin of Banshee. It is
> entirely written in Python and is currently available via Subversion. 
> Your can read my blog entry[1] about it or fetch the source directly
> from Subversion[2] and copy it to your plugins-folder.

I've attached a patch that makes lastrhythm work with Python 2.5
(elementtree is now part of python itself), fixes the cleanup a little
bit, and makes it show the widget if you turn on the plugin while
already playing.

As with some of the other plugins people have been working on, I think
this could be something a lot of people would like; so once it's got a
bit more polish, it could potentially be one of the "official" plugins.



It would be nice if it didn't block the UI while retrieving the data
from Last.FM, but that would require either pyscrobbler having
asynchronous methods or us enable threads for python plugins. The former
would be nicer, but it means someone has to write them.

I fair while ago I started writing (in C) a plugin to do things like
view your profile, and show a "top 50 tracks" source etc. Using
pyscrobbler would probably make that easier :)


Cheers,

James "Doc" Livingston
-- 
You can lead an idiot to knowledge but you cannot make him think. You
can, however, rectally insert the information, printed on stone tablets,
using a sharpened poker. -- Nicolai in asr
Index: pyscrobbler/audioscrobbler.py
===================================================================
--- pyscrobbler/audioscrobbler.py	(revision 54)
+++ pyscrobbler/audioscrobbler.py	(working copy)
@@ -270,7 +270,10 @@ __docformat__ = "restructuredtext"
 
 import datetime, locale, md5, pickle, re, site, sys, time, urllib, urllib2
 
-from elementtree.ElementTree import ElementTree
+try:
+	from xml.etree.ElementTree import ElementTree
+except:
+	from elementtree.ElementTree import ElementTree
 
 # This is lifted in the most part from iPodScrobbler  (see docs above)
 # Get the base local encoding
Index: lastrhythm.py
===================================================================
--- lastrhythm.py	(revision 54)
+++ lastrhythm.py	(working copy)
@@ -12,12 +12,21 @@ class LastRhythmPlugin (rb.Plugin):
 
 	def activate (self, shell):
 		self.shell = shell
-		player = shell.get_player  ()
-		player.connect ('playing-song-changed', self.song_change)
+		player = shell.get_player ()
+		self.psc_id = player.connect ('playing-song-changed', self.song_change)
+
+		if player.get_playing_entry():
+			self.song_change (player, player.get_playing_entry())
 
 	def deactivate (self, shell):
 		if not self.widget == None:
 			self.widget.destroy ()
+			self.widget = None
+
+		self.shell.get_player().disconnect (self.psc_id)
+		del self.psc_id
+
+		del self.shell
 
 	def song_change (self, player, entry):
 		artist = self.get_artist (entry)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]