turns YouTube live streams into podcasts
Project description
ytpodgen
command line tool to turn YouTube live streams into podcasts
prerequisite
- python3 and pip
first time setup
python3 -m pip install --user ytpodgen
Set environment variable SLACK_WEBHOOK_URL
, if you want Slack notification.
If you want to upload files to Cloudflare R2 as well, don't forget to set three environment variables for Cloudflare R2.
- R2_ENDPOINT_URL
- R2_ACCESS_KEY_ID
- R2_SECRET_ACCESS_KEY
For now, R2 bucket name must be podcast
.
examples
wait for new livestream, and once on the air, record it and generate podcast RSS in background
TITLE=<title> ; #title for your podcast
LIVEURL=<liveurl> ; #YouTube live URL that ends with "/live"
HOSTNAME=<hostname> ; #hostname to serve files from
screen -dmS ${TITLE} ytpodgen --liveurl ${LIVEURL} --title ${TITLE} --hostname ${HOSTNAME}
When completed, ytpodgen
will wait for another livestream. Since all the waiting might take a while, I prefer running this in background using screen
.
Why not upload them as well!?
You can pass --upload-r2
argument to enable file uploadig to Cloudflare R2. By enabling it, mp3s/RSS are uploaded to Cloudflare R2.
For example, by running the commands below , you create a screen session that waits for YouTube livestream on the given URL and saves the data under current directory if there is a livestream.
TITLE=<title> ; #title for your podcast
LIVEURL=<liveurl> ; #YouTube live URL that ends with "/live"
HOSTNAME=<hostname> ; #hostname to serve files from
screen -dmS ${TITLE} ytpodgen --upload-r2 --liveurl ${LIVEURL} --title ${TITLE} --hostname ${HOSTNAME}
I just want to generate RSS from mp3 files, no download/upload needed
TITLE=<title> ; #title for your podcast
HOSTNAME=<hostname> ; #hostname to serve files from
ytpodgen --title ${TITLE} --hostname ${HOSTNAME}
This generates index.rss
file under current directory and exits.
How to release
Executing the commands below, and the GitHub Actions publishes new package to PyPI.
poetry version <patch/minor/major>
git add pyproject.toml && git commit -m $(poetry version -s)
git push origin main
gh release create --generate-notes "v$(poetry version -s)"
git fetch --tags origin
Why only Cloudflare R2, and not other S3-compatible cloud storage?
Because:
- It offers free tier for up to 10GB of storage space per month
- With Cloudflare Worker, basic auth can be applied to the uploaded files that are made public
"Private Podcasts" private url or basic auth?
There are cases where you want to publish a podcast, but you don't want to make it public. In such cases, you can use two methods to make it private, "private url" or "basic auth".
"basic auth" is more secure, but it requires additional setup. "private url" is easier to setup, but it is not as secure as "basic auth". You can create private url podcast by passing --private-url
argument to ytpodgen
.
how I configured basic auth on Cloudflare R2 using Cloudflare Workers
- connected a custom domain to my R2 bucket, to make the bucket public. docs
- configured a basic auth worker by following steps described here.
- replaced the plaintext declaration of password with worker env var. docs
- added a trigger(custom domain route) to the basic auth worker. docs
TODO/IDEAS
moved to GitHub issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.