#!/usr/bin/env python # -*- coding: utf-8 -*- # ====================================================================== # Author : Terry 'Mongoose' Hendrix II # Website : http://icculus.org/~mongoose/ # Email : mongooseichiban@gmail.com # Object : # Comments: This was made to outdo snobby itunes users. # ====================================================================== import dbus import sys def ListCurrentlyPlayingSong(tagBegin, tagEnd): bus = dbus.SessionBus() #service = bus.get_object('org.gnome.Banshee', '/') #bservice = dbus.Interface(service, 'org.gnome.Banshee.Core') object = bus.get_object('org.gnome.Banshee', '/org/gnome/Banshee/Player') album = object.GetPlayingAlbum() artist = object.GetPlayingArtist() title = object.GetPlayingTitle() duration = object.GetPlayingDuration() position = object.GetPlayingPosition() rating = object.GetPlayingRating() maxrating = object.GetMaxRating() # Tags are for bolding, underlining, etc the variable strings. # Currently playing message is encoded again to be sure Japanese works. ;) s = "Playing: " s += tagBegin + title.encode("utf-8") + tagEnd s += " from " s += tagBegin + album.encode("utf-8") + tagEnd s += " by " s += tagBegin + artist.encode("utf-8") + tagEnd print s if __name__ == "__main__": args = sys.argv[1:] if not args: ListCurrentlyPlayingSong("", "") else: ListCurrentlyPlayingSong(args[0], args[1])