Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

<!-- livebook:{"autosave_interval_s":60} --> # Creating a file archive ```elixir Mix.install( [{:lastfm_archive, "~> 1.2"}], config: [ lastfm_archive: [ data_dir: "./lastfm_data/", user: "" ] ] ) alias LastfmArchive.Livebook, as: LFM_LB :ok ``` ## Introduction This is a step-by-step guide to creating a local file archive containing [Last.fm scrobbles](https://www.last.fm/about/trackmymusic), i.e. music tracks that you have been listening to. This uses the [lastfm_archive](https://github.com/boonious/lastfm_archive) tool that facilicates scrobbles downloading from the Last.fm 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](https://hexdocs.pm/lastfm_archive/transforming.html) into suitable formats for interesting analytics and visualisation. ### Prerequisite * [Setup, installation](https://hexdocs.pm/lastfm_archive/setup.html) Livebook ## Scope Run the following code (click `Evaluate` below) to find out what are you about to archive: ```elixir LFM_LB.info() ``` <!-- livebook:{"branch_parent_index":1} --> ## Archiving 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. ```elixir LastfmArchive.sync() ``` <!-- livebook:{"branch_parent_index":1} --> ## 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](https://hexdocs.pm/lastfm_archive/assets/img/livebook_heatmap.png). ```elixir LastfmArchive.default_user() |> LFM_LB.render_playcounts_heatmaps() ``` <!-- livebook:{"branch_parent_index":1} --> ## Year option `:year`: archiving scrobbles from a given year option. For example: ```elixir # change year to one containing scrobbles LastfmArchive.default_user() |> LastfmArchive.sync(year: 2023) ``` <!-- livebook:{"branch_parent_index":1} --> ## Date option `:date` archiving scrobbles from a given date ```elixir # change date to one containing scrobbles LastfmArchive.default_user() |> LastfmArchive.sync(date: ~D[2023-09-03]) ``` <!-- livebook:{"branch_parent_index":1} --> ## Overwrite option `:overwrite` any existing scrobbles, ignoring archiving status cache ```elixir LastfmArchive.default_user() |> LastfmArchive.sync(date: ~D[2023-09-03], overwrite: true) ``` <!-- livebook:{"offset":2805,"stamp":{"token":"QTEyOEdDTQ.-3jE5jxgmd1Yv8n89YD_oVWgy_VkffTIRZycMnEd_zrHVPb7cEkWq3O2s7c.EFU3eK5cSZEziLvD.jSUKVHpMDW2IbumjYNypIVl7XQZN742--J831ZPBgk_eJZetTsdMSoAqIZ_bxlgJ6LEFnGhkTx24gF0.X_dbFYSxs-YXUn3Cm4HkFQ","version":1}} -->
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×