View Source Creating a file archive

  [{:lastfm_archive, path: "elixir/lastfm_archive"}],
  config: [
    lastfm_archive: [
      data_dir: "./lastfm_data/",
      user: ""

alias LastfmArchive.Livebook, as: LFM_LB


This is a step-by-step guide to creating a local file archive containing scrobbles, i.e. music tracks that you have been listening to. This uses the lastfm_archive tool that facilicates scrobbles downloading from the API and stores them in raw JSON files.

Why? This grounds your data, backs up your music listening history, keeping it safe. You can also use the archive personally in many ways, in other applications. For example, transforming the data into suitable formats for interesting analytics and visualisation.



Run the following code (click Evaluate below) to find out what are you about to archive:


Run the follow to begin archiving. This will initate a process that fetches daily scrobbles at around every 1s (within permissable Lastfm API request rate). The process is memoised or cached. It can be halted (click Stop) and resumed without data being re-fetched. This prevents unnecessarily calls being made to the API.


Status: daily playcounts

Run the following to visualise the archiving process and progress. The code displays daily and annual playcounts stats. It also provides heatmaps visualisation. Rerun the code to get the latest status.

See a sample output.

LastfmArchive.default_user() |> LFM_LB.render_playcounts_heatmaps()

Year option

:year: archiving scrobbles from a given year option. For example:

# change year to one containing scrobbles
LastfmArchive.default_user() |> LastfmArchive.sync(year: 2023)

Date option

:date archiving scrobbles from a given date

# change date to one containing scrobbles
LastfmArchive.default_user() |> LastfmArchive.sync(date: ~D[2023-09-03])

Overwrite option

:overwrite any existing scrobbles, ignoring archiving status cache

LastfmArchive.default_user() |> LastfmArchive.sync(date: ~D[2023-09-03], overwrite: true)