GithubHelp home page GithubHelp logo

nangs / tools-for-spotify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from delight-im/tools-for-spotify

0.0 1.0 0.0 48 KB

Tools and utilities for Spotify using the Spotify Web API

License: MIT License

PHP 100.00%

tools-for-spotify's Introduction

Tools for Spotify

Tools and utilities for Spotify using the Spotify Web API

Requirements

  • PHP 7.0.0+

Installation

  1. Register your own application for the Spotify Web API

    1. Go to Spotify’s developer site

    2. Choose to create a new app

    3. Enter an arbitrary title and description for your new app

    4. Locate the “Client ID” for your new app and write it down

    5. “Edit” your app

    6. 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

    7. Locate the “Client Secret” for your app and write it down

    8. Save the new settings

  2. 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"
        }
    }
  3. Create an empty database file

    $ touch data/database.json
    # sudo chown www-data:www-data data/database.json
    # sudo chmod 0600 data/database.json

Usage

One-way synchronization between playlists

  1. 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" ]
                    }
                ]
            }
        }
    }
  2. Navigate your browser to

    http://localhost/Tools-for-Spotify/src/playlists-sync-one-way.php
    

Backing up playlists

  1. Define your desired sources in data/config.json, e.g. like this:

    {
        "playlists": {
            "backup": [
                {
                    "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx"
                },
                {
                    "which": "me:tracks"
                }
            ]
        }
    }
  2. 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
  3. Navigate your browser to

    http://localhost/Tools-for-Spotify/src/playlists-backup.php
    

Deduplicating playlists

  1. Define your desired targets in data/config.json, e.g. like this:

    {
        "playlists": {
            "deduplicate": [
                {
                    "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx"
                }
            ]
        }
    }
  2. Navigate your browser to

    http://localhost/Tools-for-Spotify/src/playlists-deduplicate.php
    

Clearing playlists

  1. Define your desired targets in data/config.json, e.g. like this:

    {
        "playlists": {
            "clear": [
                {
                    "which": "spotify:user:obhqrwlenifzujsdkvtcpa:playlist:phmcblzvgwdisqyfakrenx"
                }
            ]
        }
    }
  2. Navigate your browser to

    http://localhost/Tools-for-Spotify/src/playlists-clear.php
    

References

Contributing

All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.

License

This project is licensed under the terms of the MIT License.

tools-for-spotify's People

Contributors

ocram avatar

Watchers

anangs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.