Playing with Dbus & Songbird.... (Artwork Downloader for Songbird or any other Player supporting Dbus Interface)

Published: by

  • Categories:

Songbird comes from same family Firefox and Thunderbird. So, it would never disappoint. For everything you want, there is a addon. But, it still lacks one thing. It doesnt download the Album-Artwork automatically. When I first started using this, to add the artwork I used to search on GOOGLE IMAGES and then add them automatically.

But, then i thought its waste of time searching for each and every Album manually.

It just came to my mind that why not use DBus interface of songbird to get the current playing song TITLE and find its Album using an online service & then ultimately get its album-art.

My favourite being, I rushed to google homepage and searched for " API python" and got the result "pylast". So, i was going to use "pylast" for all my programming.

Basically i wrote a python script that contacts the Songbird for the current playing song title and artist, finds its Album through the provvided API, then downloads the corresponding ARTWORK available at… In addition, it also displays information like Album Release date.

I just love python. It could do all this in just 30 lines code….


import pylast
import getpass
import dbus
import eyeD3
import subprocess
import string
bus = dbus.SessionBus()
player_obj = bus.get_object('org.mpris.songbird', '/Player')
status = player_obj.GetStatus()

if status[0] == 0:
 print "Songbird is playing...."

current_playing_track = player_obj.GetMetadata()

print 'Title: '+current_playing_track['title']+'\nArtist: '+current_playing_track['artist']

username = "shadyabhi"
#password = getpass.getpass()
password_hash = '1552c1c2bee2fc2f472e02269417ac33'
network = pylast.get_lastfm_network(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash)

#Getting Album Info
track = network.get_track(current_playing_track['artist'],current_playing_track['title'])
album = track.get_album()
if album is not None:
 print "Album: "+album.get_name()
 print "Release Date: "+album.get_release_date()
 album_uri = album.get_cover_image(size=3)

if album is None:
 album_uri = track.get_artist().get_cover_image()
 print "ALBUM Art could not be found on :(. Now, downloading Artist Image"

print album_uri
#Downloading the Album Art from
cmd = "wget "+album_uri+" -O artwork."+album_uri[-3:]
ret =

#Editing the MetaData
tag = eyeD3.Tag()
print['location'])[7:],"%20"," "),"%27","'"))
print tag.addImage(0x08,'artwork.jpg')
print tag.update()

Future plans that I am gonna make Songbird addon, that also embeds the artwork into the mp3 file.