moc-scrobbler for MOC player.

If you want to submit your tracks to last.fm using Music on Console (dubbed MOC) this script is for you.

Contents

Documentation:

Requirements

moc-scrobbler requires a machine that knows Bash and has cURL to do the RESTful requests to lastfm. If you are on a *nix machine you should be OK.

Setup

Download or clone the script to your executable directory, some common options are:

Then run chmod +x /path/to/moc-scrobbler and reset your terminal so bash acknowledges its existence.

Connecting to lastfm

There are two ways to do this:

Using your own credentials (recommended)

The advantage of this is that you will save 2 or 3 requests to get API signatures, also if you are concerned about your listening privacy this makes more sense.

To get connected:

  1. First go to the last.fm API application page (leave the "Callback URL" field empty) and get a private key and a public key, these are two 32-bit long strings.
  2. Then run in connect mode replacing the abcdef123456789... bit with your own keys:

    moc-scrobbler --connect --api_key=abcdef123456789... --api_sec=abcdef123456789...

Using the moc-scrobbler credentials

This option will set you up to scrobble but each track you send will first call moc-scrobbler to sign the request before sending it to lastfm. Also this service may stop working at any time without prior notice!

  • Run the following and follow the setup authorizing the app to scrobble on your behalf.

    moc-scrobbler --connect

Integrating with MOC

To make MOC scrobble each song after playback you need to call moc-scrobbler after the track has been called. This is done using the OnSongChange and OnStop settings at the end of your ~/.moc/config file.

 OnSongChange = "/usr/local/bin/moc-scrobbler --update --ask-moc"
 OnStop       = "/usr/local/bin/moc-scrobbler --stop"

Remember to use the full path to moc-scrobbler and not a relative or expandable path.

Note that you must restart MOC Shift + Q for the changes to take effect.

Other options

A full list of options is:

About

--help
--version 
--about

Connecting

--connect --api_key=abcdef... --api_sec=abcdef...

Scrobbling

--artist="artist name" --track="song name"
--ask-moc

Update Current Song

--update --artist="artist name" --track="song name"
--update --ask-moc

Stop

--stop

Examples

Here is an example that scrobbles a track to lastfm, note the double quotes:

moc-scrobbler --artist="Piero Umiliani" --track="Mah Nà Mah Nà"

Remember to escape double quotes:

moc-scrobbler --artist="Lee \"Scratch\" Perry" --track="Locks In The Dublight"

Log and configuration file

The configuration file and log for moc-scrobbler are located in ~/.config/moc-scrobbler/ and it contains the following files:

  • moc-scrobbler.conf
    • contains the session key to connect to the lastfm API. This file gets overwritten every time the connect option is used.
  • scrobbles.log
    • contains a maximum of 1Mb of your most recent scrobbles (and/or errors).
  • track.current and track.last
    • contain the info about your current and last scrobbles.