Getting Album Art from last.fm

207 views
Skip to first unread message

shadyabhi

unread,
Feb 25, 2010, 9:24:36 AM2/25/10
to pylast
Hi,

I am trying to make an mp3 artwork fetcher which uses last.fm. The
script fetched the currently playing song using Dbus from songbird music
player.

I get the following error:-

shadyabhi@shadyabhi-desktop:~/python$ ./last.py
Songbird is playing....
Title: Objection
Artist: Shakira
Traceback (most recent call last):
File "./last.py", line 32, in <module>
album_uri = album.get_cover_image(size=3)
AttributeError: 'NoneType' object has no attribute 'get_cover_image'
shadyabhi@shadyabhi-desktop:~/python$

My script is as follows:-

#!/usr/bin/python

import pylast
import getpass
import dbus
import eyeD3
import subprocess
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, APIC, error

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']

API_KEY="foo"
API_SECRET="foo"
username = "shadyabhi"
password_hash = 'foo'
network = pylast.get_lastfm_network(api_key = API_KEY, api_secret =
API_SECRET, username = username, password_hash = password_hash)

#Getting Album Info
track_obj =
network.get_track(current_playing_track['artist'],current_playing_track['title'])
album = track_obj.get_album()
album_uri = album.get_cover_image(size=3)
print album_uri
track_location = current_playing_track['location']
cmd = "axel -a "+album_uri
ret = subprocess.call(cmd.split())

What can be the reason for this error?

Thanx

--
Abhijeet Rastogi
(shadyabhi)
http://www.google.com/profiles/abhijeet.1989

Amr Hassan

unread,
Feb 25, 2010, 9:55:02 AM2/25/10
to pyl...@googlegroups.com
Last.fm doesn't have album data on each track, so Track.get_album()
returns None. Get the album title from dbus and use it on an Album
object instead.

-- Amr

> --
> You received this message because you are subscribed to the pylast mailing
> list.
> To post to this mailing list, send email to pyl...@googlegroups.com
> To unsubscribe from this group, send email to
> pylast+un...@googlegroups.com
> pylast is a python wrapper around last.fm's api. the project is hosted at
> http://code.google.com/p/pylast/ and the mailing list/group is at
> http://groups.google.com/group/pylast

Reply all
Reply to author
Forward
0 new messages