https://github.com/harisekhon/spotify-tools
Spotify Tools - Playlists Backups, Spotify CLI, URI translator, duplication detection / removal, API search queries, API automation etc.
https://github.com/harisekhon/spotify-tools
bash cli golang hacktoberfest perl spotify spotify-api spotify-cmd spotify-metadata-api spotify-uri spotify-web-api tool tools
Last synced: 3 months ago
JSON representation
Spotify Tools - Playlists Backups, Spotify CLI, URI translator, duplication detection / removal, API search queries, API automation etc.
- Host: GitHub
- URL: https://github.com/harisekhon/spotify-tools
- Owner: HariSekhon
- License: mit
- Created: 2012-12-30T20:35:53.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2025-03-14T19:44:30.000Z (7 months ago)
- Last Synced: 2025-06-13T02:06:48.346Z (4 months ago)
- Topics: bash, cli, golang, hacktoberfest, perl, spotify, spotify-api, spotify-cmd, spotify-metadata-api, spotify-uri, spotify-web-api, tool, tools
- Language: Perl
- Homepage: https://www.linkedin.com/in/HariSekhon
- Size: 708 KB
- Stars: 76
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Spotify Tools
[](https://open.spotify.com/user/harisekhon)
[](https://github.com/HariSekhon/Spotify-tools/stargazers)
[](https://github.com/HariSekhon/Spotify-tools/network)
[](https://github.com/boyter/scc/)
[](https://github.com/boyter/scc/)
[](https://www.linkedin.com/in/HariSekhon/)
[](https://github.com/HariSekhon/Spotify-tools/commits/master)[](https://www.codacy.com/gh/HariSekhon/Spotify-tools/dashboard)
[](https://www.codefactor.io/repository/github/harisekhon/spotify-tools)
[](https://sonarcloud.io/dashboard?id=HariSekhon_Spotify-tools)
[](https://sonarcloud.io/dashboard?id=HariSekhon_Spotify-tools)
[](https://sonarcloud.io/dashboard?id=HariSekhon_Spotify-tools)
[](https://sonarcloud.io/dashboard?id=HariSekhon_Spotify-tools)
[](https://sonarcloud.io/summary/new_code?id=HariSekhon_Spotify-tools)
[](https://github.com/HariSekhon/Spotify-tools#spotify-tools)
[](https://github.com/HariSekhon/Spotify-tools#spotify-tools)[](https://harisekhon.github.io/CI-CD/)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/Jenkinsfile)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/cicd/.concourse.yml)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/cicd/.gocd.yml)
[](https://github.com/HariSekhon/TeamCity-CI)[](https://circleci.com/gh/HariSekhon/Spotify-tools)
[](https://buildkite.com/hari-sekhon/Spotify-tools)
[](https://ci.appveyor.com/project/HariSekhon/Spotify-tools/branch/master)
[](https://cloud.drone.io/HariSekhon/Spotify-tools)
[](https://g.codefresh.io/pipelines/edit/new/builds?id=5ec401171350573576125f8d&pipeline=Spotify-tools&projects=GitHub&projectId=5e52ca8ea284e00f882ea992&rightbar=steps&advanced=0&context=github&filter=page:1;pageSize:10;timeFrameStart:week)
[](https://cirrus-ci.com/github/HariSekhon/Spotify-tools)
[](https://harisekhon.semaphoreci.com/projects/Spotify-tools)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/buddy.yml)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/shippable.yml)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/.travis.yml)[](https://dev.azure.com/harisekhon/GitHub/_build/latest?definitionId=3&branchName=master)
[](https://gitlab.com/HariSekhon/spotify-tools/pipelines)
[](https://bitbucket.org/harisekhon/spotify-tools/addon/pipelines/home#!/)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/cicd/buildspec.yml)
[](https://github.com/HariSekhon/Spotify-tools/blob/master/cicd/cloudbuild.yaml)[](https://github.com/HariSekhon/Spotify-tools)
[](https://gitlab.com/HariSekhon/Spotify-tools)
[](https://dev.azure.com/harisekhon/GitHub/_git/Spotify-tools)
[](https://bitbucket.org/HariSekhon/Spotify-tools)[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/shellcheck.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/json.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/yaml.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/xml.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/markdown.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/validate.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/kics.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/grype.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/semgrep.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/semgrep-cloud.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/trivy.yaml)[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22GitHub+Actions+Ubuntu%22)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/mac.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/mac_11.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions/workflows/mac_12.yaml)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Ubuntu%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Ubuntu+20.04%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Ubuntu+22.04%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Debian%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Debian+10%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Debian+11%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Debian+12%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Fedora%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Alpine%22)
[](https://github.com/HariSekhon/Spotify-tools/actions?query=workflow%3A%22Alpine+3%22)[git.io/spotify](https://git.io/spotify)
Spotify tools to make it easy to:
- query and control Spotify
- backup all your Spotify playlists
- keep human-readable `Artist - Track` playlists (could migrate to another music system)My epic [Spotify Playlists](https://github.com/HariSekhon/Spotify-Playlists) collection (recently open sourced) uses this heavily.
Hari Sekhon
Cloud & Big Data Architect, United Kingdom
[](https://www.linkedin.com/in/HariSekhon/)
[](https://open.spotify.com/user/harisekhon)
*(you're welcome to connect with me on LinkedIn)*## Inventory
- bash-tools/spotify/spotify_*.sh` - [Spotify](https://www.spotify.com/) API scripts
- list all public playlists for any given user, even followed playlists
- list all private playlists for the currently authorized user
- backup all playlists or a selection of playlists by partial name or ID
- download playlist contents as Spotify URIs / `Artists - Track` / CSV format
- convert Spotify track URIs to human readable `Artist - Track` / CSV format
- iterate any command against all playlists - command can be templated with `{playlist}` name or `{playlist_id}` which will be auto-populated on each iteration
- convert a playlist name to an ID, or an ID to a playlist name
- search for tracks / artists / albums and output in either human readable form or as Spotify URIs for fast loading into the Spotify app or automated chaining with other adjacent tools
- list liked / top tracks / artists in either human readable form or as Spotify URIs
- generate a Spotify API token (used by all other bash scripts)
- query any Spotify API endpoint with authentication (used by all other bash scripts)
- `spotify-cmd.pl` - Spotify desktop app control from the command line on Mac via AppleScript calls. Useful for automation that Mac HotKeys don't help with such as auto-nexting tracks every N seconds if you want to skip through sampling a playlist## Quick Start
If you want to recover an entire deleted playlist, you can do that quickly in the Spotify web interface -> Account -> [Recover Playlists](https://www.spotify.com/uk/account/recover-playlists/) page.
For deleted songs in the desktop app, you can immediately press Control + Shift + Z on Windows or Control + Z on Mac to undo it.
This repo is for everything else - Backups, Conversions from HTTP URIs to readable `Artist - Track` format, tracking individual songs removed from playlists over time (if Spotify loses the rights to them they silently disappear and you won't notice if not Git revision controlling them like my repo [Spotify Playlists](https://github.com/harisekhon/spotify-playists) etc.
### Ready to run Docker image
These programs and their pre-compiled dependencies can be found ready to run on [DockerHub](https://hub.docker.com/r/harisekhon/spotify-tools/).
List all programs:
```shell
docker run harisekhon/spotify-tools
```Run any given program:
```shell
docker run harisekhon/spotify-tools
```### Automated Build from source
```shell
git clone https://github.com/HariSekhon/Spotify-tools
cd spotify-tools
make
```This builds all dependencies after which the programs can be run.
Alternatively see the [Manual Setup](https://github.com/HariSekhon/Spotify-tools#manual-setup) section instead.
## Examples
### Backup Spotify Playlists
Downloads the list of public playlists to `playlists.txt` (names) and `spotify/playlists.txt` (IDs + names in TSV format)
For each playlist, downloads the list of playlist tracks to a file of the same name in both human and Spotify usable formats
As it progresses, it outputs the playlist name followed by the progress of the URI download then the human readable download
`playlists/` files contain the human readable `Artist - Track` format
`playlists/spotify/` files contain the Spotify URI format (for restores or copying to new playlists)
```shell
$ ./bash-tools/spotify/spotify_backup.sh
================================================================================
Running Spotify Playlists Backup
================================================================================2020-07-05 01:23:41 Dumping list of Spotify playlists to spotify/playlists.txt
2020-07-05 01:23:43 Stripping spotify playlist IDs from spotify/playlists.txt => playlists.txt
2020-07-05 01:23:44 Backing up Spotify playlists to /Users/hari/github/spotify-tools/playlists
My Shazam Tracks => URIs OK => Tracks OK
Upbeat & Sexual Pop => URIs OK => Tracks OK
Best R&B => URIs OK => Tracks OK
Best Pop => URIs OK => Tracks OK
Best Rock => URIs OK => Tracks OK
Best Motown / Funk / Boogie / Groove / Soul => URIs OK => Tracks OK
Chill => URIs OK => Tracks OK
2019 06-07 Venice & Budapest => URIs OK => Tracks OK
2019 05 - Winchester => URIs OK => Tracks OK
2019 04 April - Bath => URIs OK => Tracks OK
2019 01 Jan - South Woodford => URIs OK => Tracks OK
2018 10 Oct - Dec => URIs OK => Tracks OK
2018 09 Sept - Dec => URIs OK => Tracks OK
2018 09 Sept => URIs OK => Tracks OK
2018 08 - Aug - Vienna => URIs OK => Tracks OK
2018 Gemma => URIs OK => Tracks OK
2018 03 March - July Mix => URIs OK => Tracks OK
2018 03 Driving Rock => URIs OK => Tracks OK
2018 02 Feb Mix - London => URIs OK => Tracks OK
2018 Jan - London - A New Beginning => URIs OK => Tracks OK
2017 12 December Mix - Back in London Baby => URIs OK => Tracks OK
2017 11 November Mix - Copenhagen => URIs OK => Tracks OK
2017 10 October Mix - Copenhagen => URIs OK => Tracks OK
2017 09 September Mix - Copenhagen => URIs OK => Tracks OK
2017 08 August Mix - London & Copenhagen => URIs OK => Tracks OK
2017 07 July Mix - Johannesburg => URIs OK => Tracks OK
2017 06 June Mix - Johannesburg => URIs OK => Tracks OK
...
2020-07-05 01:41:42 Spotify playlists backup finished in 1078 seconds
```### Convert Spotify URIs to Human readable Artist - Track
You can copy and paste the tracks from the Spotify desktop app or web player directly into text files, which puts them in Spotify URI format such as:
```none
http://open.spotify.com/track/61oGXsKgJOI0e3uS2wg1BV
http://open.spotify.com/track/1j6API7GnhE8MRRedK4bda
http://open.spotify.com/track/0RxFoUhB3mAI3qpgLSf7eM
```or
```none
spotify:track:61oGXsKgJOI0e3uS2wg1BV
spotify:track:1j6API7GnhE8MRRedK4bda
spotify:track:0RxFoUhB3mAI3qpgLSf7eM
```Then convert this to readable `Artist - Track` form for saving independently of Spotify but running `spotify_uri_to_name.sh` against the file:
```shell
$ ./bash-tools/spotify/spotify_uri_to_name.sh Pendulum.txt
Pendulum - Watercolour
Pendulum - Witchcraft
Pendulum - The Island - Pt. I
...
```You can also pipe one or more Spotify URIs through standard input in either format that Spotify uses:
```shell
$ echo http://open.spotify.com/track/5TOYgNohZAFEPOtnchPhZS | ./bash-tools/spotify/spotify_uri_to_name.sh
Foo Fighters - Arlandriaecho spotify:track:5TOYgNohZAFEPOtnchPhZS | ./bash-tools/spotify/spotify_uri_to_name.sh
Foo Fighters - Arlandria
```### Set all the tracks from your favourite playlist to "Liked"
Give the playlist file full of Spotify URIs (dumped by the spotify_backup*.sh scripts above), you can mark all the songs from your favourite playlists as `Liked Songs` which then appear in your `Liked Songs` playlist too:
```shell
spotify_set_tracks_uri_to_liked.sh playlists/spotify/My_Favourite_Playlist
```If you've been using Spotify a long time, you'll remember that marked songs used to be called `Starred`, but were replaced by `Liked Songs`. Unfortunately Spotify made `Starred` a regular playlist and didn't carry them over, but you can easily mark all previously `Starred` songs as the newer `Liked Songs`:
```shell
spotify_set_tracks_uri_to_liked.sh playlists/spotify/Starred
```### Spotify Cmd --help
```shell
$ ./spotify-cmd.pl --helpCommand line interface to Spotify on Mac that leverages AppleScript
Useful for automation that Mac HotKeys don't help with, such as auto skipping
to next track every N secs to sample a playlist while workingusage: spotify-cmd.pl
commands:
play Play
pause / stop Pause
playpause Toggle Play/Pause
previous Previous Track and print previous track information
next [secs] Next Track and print next track information.
Specifying optional secs will skip to next track
every [secs] seconds. Handy for skipping through a playlist
every 60 secs automatically and grabbing the good songs. Prints
track information every time it skips to the next trackstatus Show current track details
vol up Turn volume up
vol down Turn volume down
vol <1-100> Set volume to number <1-100>exit / quit Exit Spotify
-q --quiet Quiet mode. Do not print track information or volume after
completing action
-t --timeout Timeout in secs (default: 10)
-v --verbose Verbose mode (-v, -vv, -vvv ...)
-h --help Print description and usage options
-V --version Print version and exit
```### Manual Setup
Enter the directory and run git submodule init and git submodule update to fetch my library repo:
```shell
git clone https://github.com/HariSekhon/Spotify-tools
cd spotify-tools
git submodule init
git submodule update
```Then you will also need to fetch the following CPAN modules listed in `setup/cpan-requirements.txt` and `lib/setup/cpan-requirements.txt`:
Running the cpan command followed by the list of modules (as root) will fetch them for you, or you can use this script:
```shell
bash-tools/perl/perl_cpanm_install.sh setup/cpan-requirements.txt lib/setup/cpan-requirements.txt
```### Contributions
Patches, improvements and even general feedback are welcome in the form of GitHub pull requests and issue tickets.
### Updating
Run:
```shell
make update
```This will git pull and then git submodule update which is necessary to pick up corresponding library updates.
ndencies.If you update often and want to just quickly git pull + submodule update but skip rebuilding all those dependencies each
time then run `make update-no-recompile` (will miss new library dependencies - do full `make update` if you encounter
issues).[git.io/spotify](https://git.io/spotify)
## More Core Repos
### Knowledge
[](https://github.com/HariSekhon/Knowledge-Base)
[](https://github.com/HariSekhon/Diagrams-as-Code)### DevOps Code
[](https://github.com/HariSekhon/DevOps-Bash-tools)
[](https://github.com/HariSekhon/DevOps-Python-tools)
[](https://github.com/HariSekhon/DevOps-Perl-tools)
[](https://github.com/HariSekhon/DevOps-Golang-tools)### Containerization
[](https://github.com/HariSekhon/Kubernetes-configs)
[](https://github.com/HariSekhon/Dockerfiles)### CI/CD
[](https://github.com/HariSekhon/GitHub-Actions)
[](https://github.com/HariSekhon/Jenkins)### DBA - SQL
[](https://github.com/HariSekhon/SQL-scripts)
### DevOps Reloaded
[](https://github.com/HariSekhon/Nagios-Plugins)
[](https://github.com/HariSekhon/HAProxy-configs)
[](https://github.com/HariSekhon/Terraform)
[](https://github.com/HariSekhon/Packer-templates)
[](https://github.com/HariSekhon/Nagios-Plugin-Kafka)### Templates
[](https://github.com/HariSekhon/Templates)
[](https://github.com/HariSekhon/Template-repo)### Misc
[](https://github.com/HariSekhon/Spotify-tools)
[](https://github.com/HariSekhon/Spotify-playlists)The rest of my original source repos are
[here](https://github.com/HariSekhon?tab=repositories&q=&type=source&language=&sort=stargazers).Pre-built Docker images are available on my [DockerHub](https://hub.docker.com/u/harisekhon/).
