Skip to content

A Python library providing real-time 'now playing notifications' for Spotify

Notifications You must be signed in to change notification settings

swinton/scrobbify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

scrobbify - A Python library providing real-time 'now playing notifications' for Spotify

Overview

There's a notable lack of AppleScript support in the Spotify player, and I (along with many others) would like to do interesting things with Spotify. Things like, updating my Adium status with what I'm listening to on Spotify, sticking what's now playing in the office on an LED message panel, and doing other interesting mashups.

So, here's a workaround, using Spotify's built-in scrobbling feature. What I'm attempting to do, is capture the network packets that are sent from the Spotify player to Last.fm's API, and extract what's now playing by inspecting the HTTP request.

Yep, it's all pretty backwards, but I think it's the only viable workaround, until either Spotify adds an AppleScript dictionary, or Last.fm provides some kind of real-time webhook interface.

Usage

  1. Install scrobbify from the Python Package Index, e.g. using easy_install:

     $ easy_install scrobbify
    
  2. Be sure to enable scrobbling to last.fm in your Spotify player preferences.

  3. Use scrobbify like so:

     import scrobbify, sys
     
     def cb(now_playing, data):
         sys.stdout.write("Now playing: '%s' by '%s'.\n" % (now_playing['t'][0], now_playing['a'][0]))
         sys.stdout.flush()
         
     scrobbifier = scrobbify.Scrobbify(cb, interface='en0')
     scrobbifier.start()
     
     # Exit gracefully...
     try:
         while True:
             time.sleep(2**20)
     except (KeyboardInterrupt, SystemExit):
         scrob.stop()
    

Feedback

I'm fairly certain the code is sub-optimal right now, so feel free to leave me some feedback, via email or even twitter. :)

About

A Python library providing real-time 'now playing notifications' for Spotify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages