nightcoreify
Nightcore is mind-numbingly simple. It's just a speed-shift of a pre-existing track, with anime artwork and a visualizer slapped on top. The harsh reality is, we are wasting human minds on the creation of such low-effort "music."
I decided to take matters into my own hands and automate the process. This is a Python script that:
- finds and downloads a random (somewhat, see below) song from YouTube
- finds and downloads a random anime artwork from Reddit
- I broke tradition and went with Reddit rather than Pixiv because their API is so much friendlier.
- renders a new video, using FFmpeg, with sped up audio + image + audio visualizer
- uploads the finished product to YouTube
I currently have this script running in an AWS Lambda function, scheduled with an EventBridge rule, and uploading here every 6 hours. It's deployed on top of this Lambda layer for FFmpeg.
Clarification on "random" YouTube videos
There's no easy way to find a totally random video on YouTube, much less one belonging to a certain category (music in my case), at least that I can find, so I had to get a little creative. To find a "random" video, the script generates a 4-character string prepended with v=
(total of 6 characters), and searches for it in the music category. This typically returns videos whose IDs start with the 4-character string, but sometimes there will also be videos whose titles contain the 4-character string.
Requirements
- Python 3.8
ffmpeg
google-api-python-client
(and subsequently, a YouTube API key with upload privileges)youtube_dl
Side note: if you dig through the commits in this repo, you'll find that this used to be a Node.js script. I originally wrote it in Node to keep my options open in terms of cloud providers, but rewrote it in Python after I was sure I'd stick with Lambda.
License
This software is released under a MIT License.