← Back to team overview

gnome-zeitgeist-users team mailing list archive

Rhythmbox plugin

 

#!/usr/bin/python
 	# Display information for currently playing song
 	
 	import dbus
 	import dbus.glib
 	import gobject
 	
 	bus = dbus.SessionBus()
	
	try:
        remote_object = bus.get_object("org.gnome.Zeitgeist",
"/org/gnome/zeitgeist")

	except dbus.exceptions.DBusException:
        print >>sys.stderr, "GNOME Zeitgeist Logger: Error: Could not
connect to D-Bus."

	else:
	iface = dbus.Interface(remote_object, "org.gnome.Zeitgeist")

 	rbplayerobj = bus.get_object('org.gnome.Rhythmbox',
'/org/gnome/Rhythmbox/Player')
 	rbplayer = dbus.Interface(rbplayerobj, 'org.gnome.Rhythmbox.Player')
 	
 	def playing_uri_changed(uri):
 	print "Now playing: %s" % (uri,)
 	props = rbshell.getSongProperties(uri)
 	interesting = ['title', 'artist', 'album', 'location']
 	for prop in props:
 	if prop in interesting:
 	print "%s: %s" % (prop, props[prop])
 	
 	rbplayer.connect_to_signal('playingUriChanged', playing_uri_changed)
 	
 	x = rbplayer.getPlayingUri()
 	playing_uri_changed(x)
 	
 	loop = gobject.MainLoop()
 	loop.run()