Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/karlicoss/spotifyexport

Export your personal Spotify data: playlists, saved tracks/albums/shows, etc. as JSON
https://github.com/karlicoss/spotifyexport

backup data-liberation export spotify takeout

Last synced: 6 days ago
JSON representation

Export your personal Spotify data: playlists, saved tracks/albums/shows, etc. as JSON

Awesome Lists containing this project

README

        

#+begin_src python :dir src :results drawer :exports results
import spotifyexport.export as E; return E.make_parser().prog
#+end_src

#+RESULTS:
:results:
Export your personal Spotify data: playlists, saved tracks/albums/shows, etc. as JSON.
:end:

* Setting up
1. The easiest way is =pip3 install --user git+https://github.com/karlicoss/spotifyexport=.

Alternatively, use =git clone --recursive=, or =git pull && git submodule update --init=. After that, you can use =pip3 install --editable .=.
2. To use the API, you need to create a new app on [[https://developer.spotify.com/dashboard/applications][Spotify for Developers]]

For =redirect_uri=: you can pick pretty much anything, e.g. =https://github.com=. After that you'll get =client_id= and =client_secret=.

3. On the first script run, you'll be prompted to approve the script access.

Once approved, the token is saved to =cache_path= (will be created if doesn't exist). After that you won't need to enter the password again as long as you pass the same =cache_path=.

* Exporting

#+begin_src python :dir src :results drawer :exports results
import spotifyexport.export as E; return E.make_parser().epilog
#+end_src

#+RESULTS:
:results:

Usage:

*Recommended*: create =secrets.py= keeping your api parameters, e.g.:

: client_id = "CLIENT_ID"
: client_secret = "CLIENT_SECRET"
: redirect_uri = "REDIRECT_URI"
: cache_path = "CACHE_PATH"

After that, use:

: python3 -m spotifyexport.export --secrets /path/to/secrets.py > output.json

That way you type less and have control over where you keep your plaintext secrets.

*Alternatively*, you can pass parameters directly, e.g.

: python3 -m spotifyexport.export --client_id --client_secret --redirect_uri --cache_path > output.json

However, this is verbose and prone to leaking your keys/tokens/passwords in shell history.

I *highly* recommend checking exported files at least once just to make sure they contain everything you expect from your export. If not, please feel free to ask or raise an issue!

:end:

* API limitations

- you might want to do a [[https://www.spotify.com/uk/privacy/#privacy-center-control-section][GDPR export]] in addition, just in case

- [[https://developer.spotify.com/documentation/web-api/reference/player/get-recently-played]["Recently played"]] API endpoint **only returns the 50 most recent tracks**, which makes it kind of useless unless you export the data every hour or so.

If you care about them, might be a good idea to connect Spotify to Last.FM.

GPDR export has more tracks, but also seems incomplete (e.g. my data is missing first few years).

* Using the data

** TODO need to implement the data access bit