lastfm-summary is a command-line program for generating short textual reports of a user's Last.fm feed. It gets the relevant data from Last.fm's API, formats it into text, and emits it to standard output. It is intended to be used with scripts for sending or posting these summaries to somewhere interesting (i.e., potentially as a self-hosted version of the tweekly.fm service, targeting destinations of the user's choosing).
lastfm-summary is implemented in Haskell using the Stack build system. To build and install in your local binary path, enter stack install
in the project directory; this will automatically fetch and build all dependencies.
lastfm-summary needs a configuration file, which resides in a hidden directory in the user's home directory, and is named ~/.lastfm-summary/config
. This must contain at least a Last.fm API key (obtainable from last.fm). This may also contain a last.fm username, which will be used if no username is specified on the command line. A configuration file may look something like:
username=yournamehere
api_key=01234567012345670123456701234567
The config
file may contain the following options:
- api_key (required) - the last.fm API key; obtain this from last.fm's website.
- username (optional) - the default last.fm username of the account whose feeds to summarise. This may be overridden with the
-u
command-line option.
This program has one mandatory argument, which specifies what it must summarise. This may be one of:
- topartists - A list of the most-played artists in the last period, with play counts.
- toptracks - A list of the most-played tracks in the last period, with play counts.
- topalbums - A list of the most-played albums in the last period, with play counts.
- recent - A list of the tracks played most recently
The output of these can be controlled with these command-line options:
- -p period - specify a period (for top artists/tracks/albums); this must be one of last.fm's standard periods,
week
(the last 7 days),month
(the last month),3m
,6m
or12m
, oroverall
(of all time). Ignored for most-recent items. - -l N - specify the number of items to list. This means list the top N items, or the N most recent items.
- -u username - specify the last.fm username to query.
lastfm-summary
uses the optparse-applicative package for command-line parsing, the ConfigFile package for configuration file parsing and the Aeson package for parsing last.fm's JSON output.
lastfm-summary
currently only implements these four API endpoints (though more should be straightforward to add). It currently has no way of querying recently played tracks by cut-off dates. The output formats are currently not configurable other than by editing the code. There is not yet any facility for doing anything with the output other than printing it to stdout
; beyond that, you're on your own. Finally, this program's name is a bit unimaginative.
lastfm-summary
was written by Andrew Bulhak.