Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rrrnld/listenbrainz-to-sqlite

Dump your listenbrainz history into an SQLite database
https://github.com/rrrnld/listenbrainz-to-sqlite

datasette listenbrainz music musicbrainz

Last synced: about 1 month ago
JSON representation

Dump your listenbrainz history into an SQLite database

Awesome Lists containing this project

README

        

#+TITLE: listenbrainz-to-sqlite

This is a small Python utility to fetch all of the listening history of a single user from [[https://listenbrainz.org/][listenbrainz]] and store it in an SQLite database so it can be explored for and queried using the fabulous [[https://datasette.io/][datasette]] toolkit. It uses the [[https://musicbrainz.org/][musicbrainz]] api to fetch additional information about releases, recordings, and artists.

[[file:screenshot.png]]

This graph shows how many different releases (i.e. albums) I listened to on each day.

#+begin_src
$ poetry run import_listens --help

Usage: import_listens [OPTIONS]

Imports listenbrainz history of a single user with associated artists,
releases, and recordings.

Options:
--user TEXT The Listenbrainz username for which to
import listens. [required]
-n, --max-results INTEGER Limit the maximum amount of fetched results.
-s, --since [%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]
Consider only listens more recent than this
argument.
-t, --until [%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]
Consider only listens older than this
argument.
-u, --update [artists|recordings|releases|*]
Fetch information from Musicbrainz even if
it already exists locally. Setting this
argument to '*' will re-fetch all
information. Use this flag multiple times to
update multiple resource types.
--help Show this message and exit.

#+end_src

You should be able to update the database continuously as your listening history grows. If that doesn't work it's a bug.

** Why would I want to do that?

Because it's a neat way to get an overview over your personal listening history. Spotify sucks, but the insight it allows you into your musical behavior is in parts quite cool. My hope is that this will make it easier to do similar things.

Additionally, I think this provides value because the information on the different *brainz is vast, but also widely scattered. I hope that this makes it easier to work with it.

The poetry environment comes with datasette dev dependencies including plugins to create vega graphs and save custom queries, so a simple =poetry run datasette .= allows you to examine your listening history and get something like depicted on the screenshot above.

Please note that this is written for fun, the code is probably buggy and possibly not very pythonic. :)

** Roadmap

- [ ] Evaluate additional info from Musicbrainz
- [ ] Integrate Acoutsicbrainz