Spotify and Tunefind Bridge Simple CLI
Project description
spotifind
Combined Spotify and Tunefind Simple Command Line Tool
Tunefind is a music search website, which helps find music featured in television series and movies. Users can suggest songs related to TV shows or movies. If approved, the song will be listed on that page.
Spotify is a digital music streaming service that gives you access to millions of songs, podcasts, and videos from artists worldwide, like Apple Music and Amazon Music Unlimited.
Over the last week, as people are cooped up working from home, I thought it would be a fun project to think about soundtracks. In addition, I was getting a new Spotify premium account. Though you can probably find public playlists for almost any TV series, I thought it would be fun to link Tunefind and Spotify to do this for user-generated TV show lists.
Spotifind (Spotify+Tunefind) is a tool designed to authorize and authenticate your Spotify API and work with Tunefind to search for and create playlists.
There are two requirements for this tool:
- You have a Spotify account
- Create a new [spotify client here]
Spotify client setup needs two main steps
- The Client ID and Client Secret
- Setting up a redirect URI; you use this to redirect the authorization flow for Spotify. In short, once you authorize your app, the redirect URI will open along with a code that allows for authorization. I use "http://google.com," but you can use whatever you would like.
Let's go back to the problem and the setup.
> spotifind -h
usage: spotifind [-h] {spot_init,spot_auth,spot_refresh,spot_tune} ...
Spotify and Tunefind Bridge Simple CLI
positional arguments:
{spot_init,spot_auth,spot_refresh,spot_tune}
spot_init Initialize Spotify & setup client credentials
spot_auth Authorize Spotify Client and get access and refresh
tokens
spot_refresh Refresh spotify token
spot_tune Tunefind playlist to spotify playlist
optional arguments:
-h, --help show this help message and exit
Install now
pip install spotifind
Spot Init
You only have to do this once. This takes a few things into account: your client id and your client secret (don't worry, your client secret is not stored in clear text or anywhere). It holds three specific things,
- your client id
- base64 encoded clientid:clientsecret (Since base64 encoding is not encryption, it is possible to decode this, so try to use this app on your personal computer or virtual machine: Don't worry, you can always reset your client secret)
- Redirect URI we set earlier
Run
spotifind spot_init
Spot Auth
This is the authorization setup; this uses your client id and client secret file you set up using spot_init. Copy and paste the redirect URI, and you should be able to create the auth.json credentials file, which has the following setup. The setup includes all scopes; in the future, the idea would be for a user to send out the scopes they want to access simply. Therefore, I kept all possible scopes active.
{
"access_token": "BQzxzRkNgSxJm0mEc..............lq74SenuW0lFEIqKjJF",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "AQD80AT2u..............85j2Hk579vTQkstZG-dinGDK7L4",
"scope": "playlist-read-private playlist-read-collaborative user-follow-read playlist-modify-private user-read-email user-read-private user-follow-modify user-modify-playback-state user-library-read user-library-modify playlist-modify-public user-read-playback-state user-read-currently-playing user-read-recently-played user-top-read"
}
The tool setup is as follows.
> spotifind spot_auth -h
usage: spotifind spot_auth [-h] [--overwrite OVERWRITE]
optional arguments:
-h, --help show this help message and exit
Optional named arguments:
--overwrite OVERWRITE
Type yes to overwrite existing
If you have already done this step but want to use a different client or different account, you can use the setup.
spotifind spot_auth --overwrite "yes"
Spot refresh
This will be used all the times; though your access token expires every one hour, the refresh token can be used to generate new access tokens. You won't necessarily need this tool, but it is built in and used as a module for the spot_tune tool to create the playlist by first refreshing the access token. Setup is simply
spotifind spot_refresh
Spot Tune
This is the main tool used to convert a Tunefind series URL to a spotify playlist and add it to your account. The tool adds some features such as
- Checking for the existing playlist in case you want to use an existing playlist
- Checking if songs exist in the playlist, so the same songs are not added twice
- Since you can only add 100 songs simultaneously, it also iterates through the song list and adds it to the playlist in chunks.
The tool setup is
> spotifind spot_tune -h
usage: spotifind spot_tune [-h] --url URL --name NAME --desc DESC --playlist
PLAYLIST
optional arguments:
-h, --help show this help message and exit
Required named arguments.:
--url URL Tunefind series url
--name NAME Spotify playlist name
--desc DESC Spotify Playlist Description
--playlist PLAYLIST public or private
The setup was
spotifind spot_tune --url "https://www.tunefind.com/show/self-made-inspired-by-the-life-of-madam-cj-walker" --name "walker" --desc "playlist-test" --playlist private
This was a weekend project and so much fun to implement. For now, this will be maintained ad hoc, and I hope to add more Spotify tools inspired by some fantastic projects out there. Since you are authorizing yourself with all scopes, why not explore more :)
Changelog
v0.0.6
- Pull 3
- fix paths changed by Tunefind
- parsing more robust and better logging
- fixed typos in code and ReadMe
v0.0.5
- Pull request 2
- fix old css classes, keep tracks sorted
v0.0.4
- Replaced fuzzywuzzy with rapidfuzz
v0.0.3
- Added pagination to get all tracklist
- Overall improvements
- Applied Fuzzy song search
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spotifind-0.0.6.tar.gz
.
File metadata
- Download URL: spotifind-0.0.6.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cb6dc998af4715109322e9d231c90c6c53ce08b180e976a94cd75aac29c5e99 |
|
MD5 | a15a128810347ac1930ae64a3fa6d553 |
|
BLAKE2b-256 | 7f39b2adbdcb6503df36296b915ed668b535211a5b12998766f12f882d4347a7 |
File details
Details for the file spotifind-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: spotifind-0.0.6-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d3241cd4009495a6ae1da30473fd24a68fa77ffa34c1723b498531200e6e50a |
|
MD5 | 1e210022a11368fd5527626daef98947 |
|
BLAKE2b-256 | 97b135e56907fe0bbe38d1e97b09f51f0c0b9c1869c04a757c3cdc88609187ff |