Lastfm #scrobbles

I’m looking to write a plugin that can grab the number of times each song in my library has been scrobbled to lastfm, total by all users. I have used the lastimport and lastgenre plugins to grab playcount info from lastfm from my personal user account and genre info. I’m thinking I might be able to do something similar here to build a playlist/music recommendation system for a very large library. Looking for some guidance from other users who might have some ideas on how to adapt those plugins. Thanks!

Ok, I’ve been messing around with this off and on. Here is what I have come up with:

I made a smartplaylist that can sort by a flexible attribute called play_count, this works well, for example:

    relative_to: ~/Music
    playlist_dir: ~/beets/playlists
    playlists:
        - name: play_count_test.m3u
          query: 'title: play_count: play_count-'

        - name: play_count_rock.m3u
          query: 'genre: Rock title: play_count: play_count-'

Then I went about trying to write a plugin for beets to get this info from last.fm. I got this to work by struggling with how to turn it into a plugin and store the flexible attributes in the database. So far I have figured out how to get the playcounts from pylast using either MBID or artist/track:


from beets import plugins

LASTFM = pylast.LastFMNetwork(api_key=plugins.LASTFM_KEY)

track = LASTFM.get_track_by_mbid("1981c7d2-6c89-4c53-935a-890d937159b9")

count = track.get_playcount() 

count

3057535