Tom
Tom

Reputation: 435

Is it possible to get scrobbles and listeners from the Last.FM API?

I am using Python to gather information in Artists.

Among other sources I want to use Last.FM an scrape information on Scrobbles and Listeners per Artist.

Can somebody tell me whether this is possible via an API or whether I should give BeautifulSoup a shot and parse the HTML?

I am already using the pylast module for Python but could not figure out how it should work.

Upvotes: 3

Views: 1447

Answers (1)

Hugo
Hugo

Reputation: 29354

Here's how to do it with pylast:

#!/usr/bin/env python
import pylast

# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from http://www.last.fm/api/account for Last.fm
API_KEY = "TODO_ENTER_YOURS"
API_SECRET = "TODO_ENTER_YOURS"

lastfm_network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET)

artist = lastfm_network.get_artist("Test Artist")

print "Listeners:", artist.get_listener_count()
print "Scrobbles:", artist.get_playcount()

Outputs:

Listeners: 851
Scrobbles: 3434

Upvotes: 1

Related Questions