On reddit.com/r/kpop, there is a wonderfully-mintained wiki that keeps track of all the musical releases from various K-Pop artists. The wiki is updated every month with a table full of info about the releases. Here is a link to the wiki.
This script parses that wiki table, extracts the YouTube Music links to the releases, and then puts them into a playlist on YouTube Music.
The playlists can be found on music.youtube.com.
The script basically does the following:
- Gets the current month + year
- Grabs the current-month's releases wiki from Reddit
- Extracts out all the YouTube Music links currently in the wiki
- Fetches the YouTube Music playlist for the corresponding month + year, or creates one if doens't exist
- Inserts each of the releases into the playlist
The main logic is written in Python3 with SQLite3 as the data store.
Simple as just
python script.py
Rather than virtualenv, this setup uses Docker because I find it easier to work with. The script is invoked every 15 minutes via a cronjob.
This script uses an unofficial YouTube Music API via the amazing ytmusicapi
library. Google does not provide an official client and this works great.
Due to the lack of official client, ytmusicapi
utilizes actual session-based request headers for authentication rather than access tokens. So you will need to follow the setup instructions to get authentication working.
So, to run this yourself, you will need to follow the setup instructions and add a headers_auth.json
file for the library.
The database is dead simple. Just two tables.
playlists
— which stores the YouTube Music ID for the playlist of a given month + yearprocessed
— which is just a list of all the raw-links that we have already-handled from the reddit wiki
Can see the specifics in the youtube.db.schema
file.