Skip to main content

ytpodgen

Code style: black

Command line tool to turn YouTube live streams into podcasts. It watches out for new YouTube live streams, and once on the air, records the livestream, converts it to audio file, generates podcast RSS, and uploads them to Cloudflare R2.

prerequisite

  • python3 and pip

Tested only on Mac and Linux.

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.

usage

usage: ytpodgen [-h] --title TITLE --hostname HOSTNAME [--liveurl LIVEURL] [--upload-r2] [--output OUTPUT] [--bucket BUCKET] [--private] [--version]

Podcast generator

options:
  -h, --help           show this help message and exit
  --title TITLE        title for the podcast
  --hostname HOSTNAME  hostname(custom or r2.dev) to serve files
  --liveurl LIVEURL    Watch for and download the specified YouTube Live URL.
  --upload-r2          If specified, upload mp3s/RSS to Cloudflare R2.
  --output OUTPUT      Output directory(default: current directory)
  --bucket BUCKET      R2 Bucket name to upload files(default: podcast)
  --private            If specified, make the podcast private by generating hashed url.
  --version            Show version and exit.

examples

MY USE CASE: wait for new livestream in background, and once on the air, record it, generate podcast RSS, and upload them to Cloudflare R2

screen -dmS <TITLE> ytpodgen --liveurl <LIVEURL> --title <TITLE> --hostname <HOSTNAME> --upload-r2

When completed, ytpodgen will wait for another livestream. Since all the waiting might take a while, I prefer running this in background using screen.

a few options you might wanna take a look at

private

When you want to make a podcast private, using basic auth to restrict access is the best way to go. However, it requires additional setup, and some podcast apps don't support basic auth.

By passing this option, you can generate hashed url for the podcast. It is far less secure than basic auth, but it is easier to setup, and it works with most podcast apps.

I'm using this option to sync audiobook files to the podcast app on my Garmin smartwatch.

bucket BUCKET

By default, ytpodgen uploads files to podcast bucket. If you want to upload files to a different bucket, you can specify it with this option.

I'm using this option to switch between a bucket that is password protected by basic auth, and a bucket that is not. Be careful what to pass to the --hostname option when you use this option, as the hostname must match the bucket name.

I just want to generate RSS from mp3 files, no download/upload needed

ytpodgen --title <TITLE> --hostname <HOSTNAME>

This generates index.rss file from the mp3 files in 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

how I configured basic auth on Cloudflare R2 using Cloudflare Workers

  1. connected a custom domain to my R2 bucket, to make the bucket public. docs
  2. configured a basic auth worker by following steps described here.
  3. replaced the plaintext declaration of password with worker env var. docs
  4. added a trigger(custom domain route) to the basic auth worker. docs

TODO/IDEAS

moved to GitHub issues

Metadata

Release files for ytpodgen 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ytpodgen 0.3.2
File Size Uploaded
ytpodgen-0.3.2.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ytpodgen 0.3.2
File Interpreter ABI Platform
ytpodgen-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / ytpodgen-0.3.2.tar.gz

Download URL ytpodgen-0.3.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
139c85e4ca5c0b8233d854abbaf551434b4138ef976f42ca5990cf8036179b3a
BLAKE2b-256 checksum
How to use checksums
63f9b2483866399fbed06250bbffe9290307c7101a24db2d5cc7a04bd0cf438f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / ytpodgen-0.3.2-py3-none-any.whl

Download URL ytpodgen-0.3.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ce10ad8e04a19862bbfa4188500e7e063663e94691b8b96b8e7b44458eed4a0
BLAKE2b-256 checksum
How to use checksums
4f876401243549012a18ee117a1640bc746dbbb2af4dcbfe9f51d8c26e85da64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page