Code Monkey home page Code Monkey logo

spotify-utils's Introduction

Spotify utils

Various python scripts for spotify automation

Setup

1. Requirements

  • Spotify account
  • Python 3 with pip installed
  • Git installed

2. Create spotify application

  1. Go to Spotify Developers Dashboard and login to your spotify account.
  2. Create new application or use existing one.
  3. Add http://localhost:8080 (or any URL you want) as a redirect URI.

3. Download and install dependencies

git clone https://github.com/upedd/spotify-utils
pip install -r requirements.txt

4. Set environment variables

  • SPOTIPY_CLIENT_ID - client id of your spotify application
  • SPOTIPY_CLIENT_SECRET- client secret of your spotify application
  • SPOTIPY_REDIRECT_URI - redirect URI of your spotify application

Usage

Artist Playlist (artist_playlist.py)

Creates playlist with tracks from given artist albums.

usage: artist_playlist.py [-h] [-i ID] [-v {public,private}] [-a] [-m]
                          [-r REGION] [-d]
                          playlist_name

positional arguments:
  playlist_name         name of generated playlist

optional arguments:
  -h, --help            show this help message and exit
  -i ID, --id ID        artist id
  -v {public,private}, --visibility {public,private}
                        playlist visibility (default: private)
  -a, --appearances     include appearances in other artists albums
  -m, --mentioned       include only tracks that given artist is mentioned as
                        track artist
  -r REGION, --region REGION
                        include only tracks that are playable in this region
                        (f.e. "PL")
  -d, --deduplicate     remove duplicates based on title
Example:
$ python artist_playlist.py test -i 1Xyo4u8uXC1ZmMpatF05PJ -a -m -r PL
=== Spotify playlist creation helper by uped (https://github.com/upedd) ===
Fetched 361 albums...
Fetched 2450 tracks...
Got 591 tracks in which given artist is mentioned in track artists...
Got 320 tracks which are playable in given region (PL)...
Created playlist "test" https://open.spotify.com/playlist/1L6NRrtxxPFOUqypVygSg6...
Added all tracks to playlist...
Execution completed in 6.02 seconds.

Interactive mode

If --id argument is missing script will run in interactive mode which helps you with specifying options and allows you to search for an artist.

Example of interactive mode:
$ python artist_playlist.py test
=== Spotify playlist creation helper by uped (https://github.com/upedd) ===
Running in interactive mode! You can skip this by specifying "--id" argument
Do you have an artist id? (y/N): n
Enter an artist name: weekend
1. The Weeknd (https://open.spotify.com/artist/1Xyo4u8uXC1ZmMpatF05PJ)
2. Weekend (https://open.spotify.com/artist/4jPwc1E9EXPQbryc1YKbjl)
[...]
Enter a index of artist you want to select: 1
Artist ID: 1Xyo4u8uXC1ZmMpatF05PJ
Do you want to make your playlist public? (y/N): n
Include appearances in other artists albums? (y/N): y
Include only tracks that given artist is mentioned as track artist? (y/N): y
Include only tracks that are playable in specified region? (y/N): y
Enter that region (f.e "PL"): PL
Remove duplicates based on title? (y/N): n
Fetched 361 albums...
Fetched 2450 tracks...
Got 591 tracks in which given artist is mentioned in track artists...
Got 320 tracks which are playable in given region (PL)...
Created playlist "test" https://open.spotify.com/playlist/{id}...
Added all tracks to playlist...
Execution completed in 4.8 seconds.

Authors

License

MIT

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.