Skip to main content

Generate Spotify playlists from a few REST services

Project description

Spotijjjy

A python script to generate Spotify playlists from rest services. Currently works for Any ABC (Australian Broadcasting Corporation) radio stations and with the subreddit /r/listentothis.

Originally designed for Triple J - thus the name.

Inputs

ABC

Any ABC (Australian Broadcasting Corporation) radio station
Known ABC stations are: jazz,dig,doublej,unearthed,country,triplej,classic
You can choose what timeframe to create a playlist from, it defaults to the previous aired standard morning and afternoon sessions

Reddit

The subreddit 'listentothis'. Ranges can be any of day,week,month,year,all

Setup

From source

# Clone the repo
git clone git@github.com:maxtara/Spotijjjy.git
cd Spotijjjy

# Create a [virtualenv](https://virtualenv.pypa.io/en/stable/)
virtualenv env
source env/bin/activate

# install requirements
pip install -r requirements.txt

From pip

pip install spotijjjy  

Spotify Intructions

To get a Spotify client id, client secret and refresh token, follow instructions at Spotify Web API Tutorial

Oauth token store

The oauth token needs to be stored to be refreshed, there are currently two storage options, DynamoDB or a file, specified in the STORE option below.
If storing the oauth token in DynamoDB, the key to store it is 'spotijjjy_token'.

If using the DynamoDB store, boto3 is required - pip install boto3

CLI Usage

usage: python -m spotijjjy.main config.json abc:station_id    playlist_id <STORE>
usage: python -m spotijjjy.main config.json reddit:subreddit  playlist_id <STORE>

e.g.: python -m spotijjjy.main config.json doublej 2jhfs98s3finafzgfse9u3 file:foo.txt [ranges]
e.g.: python -m spotijjjy.main config.json triplej sfiujh38f9hs983fjs3fj9 dydb:tablename [ranges]

Optional argument ranges differs for each input.

For abc, it is in the format - comma seperated list of from%to in iso format.
e.g. 2020-01-01T12:00:00%2020-01-01T13:00:00,2020-02-01T12:00:00%2020-02-01T13:00:00
turns into 
    from - 2020-01-01T12:00:00
    to   - 2020-01-01T13:00:00 
and from - 2020-02-01T12:00:00
    to   - 2020-02-01T13:00:00

For reddit, it is in the format "period,limit" where period is one of day,week,month,year,all and limit is 1-100"

Deploy on Serverless (AWS Lambda) Setup

Requires serverless (sls) to be installed, and aws credentials setup. More help here: https://www.serverless.com/framework/docs/getting-started/

sls plugin install --name serverless-python-requirements
sls deploy

Arguments are passed in a env variables, which you can put in the serverless.yml, or a secrets.json like the yaml provided.

Notes

Spotify searching

I do my best to find the correct song via the spotify search api, using a variety of methods. I use Multiple API options (searching with the artist, or artists, or full text search), and from the returned search results, I try to find the exact song using fuzzy string matching. YMMV

Deploying

pytest -vs
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

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

spotijjjy-1.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotijjjy-1.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file spotijjjy-1.1.0.tar.gz.

File metadata

  • Download URL: spotijjjy-1.1.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spotijjjy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fe8c7ca826a13df036a426c60d037b5f7f59b476dcc3173687d70e378f312587
MD5 6c6dea1f699ba6c14b7b1fb94bdf7504
BLAKE2b-256 e811842c1e88708f181804101e3fc20f248d07650b958c86d5b49f0730987c4a

See more details on using hashes here.

File details

Details for the file spotijjjy-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: spotijjjy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spotijjjy-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74a16b8b79ebfd0179ec59df434b18829826af80b69ba61598c3f2941e25525c
MD5 330591f1089063ceef9d8056fd32a33c
BLAKE2b-256 a09b3ea6d482c439257822792c0bfe59429e6381b1e7011b1f1ed50ea06d7b5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page