Spotify had a really charming summer sale, three months for 100 yen, and that was more inviting than what I could resist. As a result, I’ve been listening to various artist radios at home too (without premium it wouldn’t let the desktop client on).

Now that it works, of course I’d occasionally want to post #nowplaying tweets/toots too, so I added that functionality to my script. From the experience with fixing it for Clementine the other day, it was really easy.

I just changed the DBus-reader function as such:

def get_clem():
  try:
    return bus.get_object('org.mpris.MediaPlayer2.clementine', '/org/mpris/MediaPlayer2')
  except DBusException as e:
    try:
      return bus.get_object('org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
    except DBusException as e:
      print e
      sys.exit(1)

And now it works. All is good. (As obvious, Clementine takes precedence.)

Also, I fixed some stuff and uploaded the code to Github. Enjoy.