Tools and utilities for Spotify using the Spotify Web API
- PHP 7.0.0+
-
Register your own application for the Spotify Web API
-
Go to Spotify’s developer site
-
Choose to create a new app
-
Enter an arbitrary title and description for your new app
-
Locate the “Client ID” for your new app and write it down
-
“Edit” your app
-
As a “Redirect URI”, add
http://localhost/Tools-for-Spotify/src/playlists-sync-one-way.php http://localhost/Tools-for-Spotify/src/playlists-backup.php http://localhost/Tools-for-Spotify/src/playlists-deduplicate.php http://localhost/Tools-for-Spotify/src/playlists-clear.php
using whatever may be the URL to your (local) version of this project
-
Locate the “Client Secret” for your app and write it down
-
Save the new settings
-
-
Create an empty configuration file
$ touch data/config.json # sudo chown www-data:www-data data/config.json # sudo chmod 0400 data/config.json
Add your “Client ID” and “Client Secret” for the Spotify Web API, e.g.:
{ "api": { "clientId": "u64v81mhz2ntxrilbkpfyd9q07oegjsc", "clientSecret": "wqyt6dbnk7235faxmre4c1lzhpvius80" } }
-
Create an empty database file
$ touch data/database.json # sudo chown www-data:www-data data/database.json # sudo chmod 0600 data/database.json
-
Define your desired sources and targets in
data/config.json
, e.g. like this:{ "playlists": { "sync": { "oneWay": [ { "from": "spotify:user:spotify:playlist:wvfdktjeqiurxghbymlzan", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx" }, { "from": "spotify:user:ehkuimfzcpvdjxblorsgny:playlist:zlebkwmgyvtjrnudqacsix", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:gouscewqprnbkzhajyixvt", "whereYearIn": [ 2010 ] }, { "from": "spotify:user:spotify:playlist:htkwibrfuvlyzdmxngqpaj", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:ulzhcpatfomqsvbynijwgd", "whereYearIn": [ 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 ] }, { "from": "me:tracks", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:kmnwohlftdxycsjgubvqea" }, { "from": "me:tracks", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:QXe53JVVBXNUKSq5DVqvmt", "whereAnyArtistIn": [ "Jane Doe" ] }, { "from": "me:tracks", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:wTSJoQhAQqBVMOmxXfN59a", "whereAnyArtistNotIn": [ "9HfCfBYiosO7t62GILFGxB", "LrN6zjcmbUqA0HCXIlNPVL" ] }, { "from": "spotify:user:spotify:playlist:KA2A81ktI0MXEPbtGlZs0S", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:YxUE0blqg47ipugIas7LhT", "whereAllArtistsIn": [ "John Doe", "twba9w5BGoQilbkB3mTNW2", "Jane Doe" ] }, { "from": "spotify:user:spotify:playlist:VaOezYffujjiSF3BQnCCeu", "to": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:9GiNzhW3zqDW9CkkKVbyyo", "whereAllArtistsNotIn": [ "wUHkEcqvsWEOq6h85BYs4R" ] } ] } } }
-
Navigate your browser to
http://localhost/Tools-for-Spotify/src/playlists-sync-one-way.php
-
Define your desired sources in
data/config.json
, e.g. like this:{ "playlists": { "backup": [ { "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx" }, { "which": "me:tracks" } ] } }
-
Make sure that the
backups
directory is writable by the web server, e.g. using the following command:$ sudo chown www-data:www-data backups
-
Navigate your browser to
http://localhost/Tools-for-Spotify/src/playlists-backup.php
-
Define your desired targets in
data/config.json
, e.g. like this:{ "playlists": { "deduplicate": [ { "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx" } ] } }
-
Navigate your browser to
http://localhost/Tools-for-Spotify/src/playlists-deduplicate.php
-
Define your desired targets in
data/config.json
, e.g. like this:{ "playlists": { "clear": [ { "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx" } ] } }
-
Navigate your browser to
http://localhost/Tools-for-Spotify/src/playlists-clear.php
All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.
This project is licensed under the terms of the MIT License.