Get a copy of the contents of the *SCROBBLE-CACHE*.
When valid (as determined by VALID-SCROBBLE-P), add a song to the queue to be
scrobbled. If there is a network failure, the track will be stored for later
scrobbling when a connection is reestablished.
Ensure needed variables are set, restore the cache and settings if present
and, if scrobbling is enabled, restore or acquire a session key.
Loop indefinitely. If there are at least *SCROBBLE-COUNT* songs queued,
scrobble until the queue is empty or errors occur. Sleep 2 minutes and repeat.
Update the now playing status when *NOW-PLAYING-P* is non-NIL.
Toggle whether or not the Now Playing status is updated with each song.
Toggle whether or not new songs are added to the queue.
Set *LAST-SEEK* to the current track position via *SONG-TIME-FN*.
Set *SKIPPED* to the current track position via *SONG-TIME-FN*.
Set *SONG-INFO* to a list of (track artist duration timestamp) via
*SONG-INFO-FN* and UNIX-TIMESTAMP.
ADD-LOG-ENTRY (&REST ARGS)
Format ARGS and append the line to the cl-scrobbler log file, creating it
if it does not exist.
Add the SCROBBLE to the cache and serialize it to disk.
Peek at *SCROBBLE-CACHE* and attempt to scrobble the next song. If
successful, remove the song from the cache and persist it to disk.
Return a pathname for NAME under *CONFIG-DIR* ensuring the directory exists.
Retrieve the error message corresponding to the number ERRCODE.
Lispify Last.fm method names. i.e. "auth.getToken" -> 'get-token
camelCase Lisp symbols. i.e. 'frob-lisp-symbol -> "frobLispSymbol"
Get a Session Token for scrobbling. Last.fm recommends storing these
in a secure fashion as they generally have an infinite lifetime.
Attempt to retrieve session key from disk. If it is not present, authorize
a new session with last.fm and store the key for future use.
Get an Unauthorized Token for initiating an authenticated session.
GETJSO (KEY MAP)
Fetch a value from a JS object. Returns a second value like
SETFGETJSO (VAL KEY MAP)
Store a value in a JS object.
LASTFM-CALL (PARAMS &KEY (METHOD GET))
Make an HTTP request to the *API-URL* with the specified METHOD and PARAMS.
PARAMS should be a list of dotted pairs.
MAKE-PARAM (SYM VAL)
Return a cons, or list of conses if VAL is a list, suitable for use as a POST
parameter or GET queryparam in a last.fm call. SYM is converted to a camelCase
string and, if VAL is a list, append C-style array indices to SYM.
Construct an API method signature from PARAMS.
Creates an MD5 byte-array of STRING and prints it as lower-case hexadecimal.
Persist the cache to disk.
Remove the last scrobble from the cache and persist the cache.
Ask the user to authorize cl-scrobbler to submit songs.
Restore the cache from disk.
Restore the *SCROBBLE-COUNT*, *SCROBBLE-P* and *NOW-PLAYING-P* variables.
Persist the *SCROBBLE-COUNT*, *SCROBBLE-P* and *NOW-PLAYING-P* settings.
SCROBBLE (TRACK TIMESTAMP ARTIST SK)
Scrobble the track!
Lispify camelCase or CamelCase strings to camel-case.
This is a very naive lisp symbol to camel-case converter. It is not designed
to be robust, merely to handle local variables in the typical lisp style.
STRING-TO-OCTETS (STRING &KEY (EXTERNAL-FORMAT LATIN1) (START 0) (END (LENGTH STRING)))
Converts the Lisp string STRING from START to END to an array of
octets corresponding to the external format designated by
In spite of the name, STRING can be any sequence of characters, but
the function is optimized for strings.
Cross-implementation abstraction to get the current time measured from the
unix epoch (1/1/1970). Should return (values sec nano-sec).
UPDATE-NOW-PLAYING (TRACK ARTIST SK)
Update the Now Playing status on last.fm.
Last.fm defines a valid scrobble as a track that is over 30 seconds long
which has been played for over half its length OR 4 minutes. We extend this
notion such that playtime must have occurred without seeking.