Skip to main content

turns YouTube live streams into podcasts

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ytpodgen-0.3.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytpodgen-0.3.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file ytpodgen-0.3.2.tar.gz.

File metadata

  • Download URL: ytpodgen-0.3.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ytpodgen-0.3.2.tar.gz
Algorithm Hash digest
SHA256 139c85e4ca5c0b8233d854abbaf551434b4138ef976f42ca5990cf8036179b3a
MD5 df0d3276508b4865cf5ace3d9e8d5386
BLAKE2b-256 63f9b2483866399fbed06250bbffe9290307c7101a24db2d5cc7a04bd0cf438f

See more details on using hashes here.

File details

Details for the file ytpodgen-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: ytpodgen-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ytpodgen-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ce10ad8e04a19862bbfa4188500e7e063663e94691b8b96b8e7b44458eed4a0
MD5 e708796fc3e3ff9d42f6bc4128dab8df
BLAKE2b-256 4f876401243549012a18ee117a1640bc746dbbb2af4dcbfe9f51d8c26e85da64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page