A Python script that when run, takes all the newest videos in a YouTube playlist, and POSTs it to a discord webhook. Or at least, it's supposed to.
A note: I wrote this to introduce myself to Python. The code is a mess, and whether it'll work is... iffy. Use at your own risk.
Additionally, I have no real intention of maintaining this. things may be broken down the line. Apologies.
Look over the YouTube Data API Overview in order to obtain your API key, alternatively the necessary steps have been copied below.
- Create a new project in the Google Developers Console and obtain authorization credentials so your application can submit API requests.
- After creating your project, make sure the YouTube Data API is one of the services that your application is registered to use:
- Go to the API Console and select the project that you just registered.
- Visit the Enabled APIs page. In the list of APIs, make sure the status is ON for the YouTube Data API v3.
- Edit the .env (or set up your environment variables):
ApiKey = # youtube api key...
PlaylistID = # the youtube playlist ID (the part after `playlist?list=`)
WebhookUrl = # the webhook url.
EmbedText = # the message you want to be sent with the embed. defaults to: `New video in playlist!` you can also say `videoURL` to send the video's URL.
- Install all dependencies with
pip install -r requirements.txt
- Run
main.py
.- Optionally, use
--offset [seconds]
to filter videos added [seconds] ago.
- Optionally, use
Consider running a cron job, using GitHub Actions, or just some looping script to run this at a regular interval.
The Unlicense. Do whatever you want with it.