Metadata-Version: 2.1
Name: ytpodgen
Version: 0.2.0
Summary: turns YouTube live streams into podcasts
Author: harupong
Author-email: harupong@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: boto3 (>=1.26.89,<2.0.0)
Requires-Dist: click (>=8.1.3,<9.0.0)
Requires-Dist: loguru (>=0.6.0,<0.7.0)
Requires-Dist: podgen (>=1.1.0,<2.0.0)
Requires-Dist: requests (>=2.28.2,<3.0.0)
Requires-Dist: yt-dlp (>=2023.3.4,<2024.0.0)
Description-Content-Type: text/markdown

# ytpodgen - turns 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> ;\
LIVEURL=<liveurl> ;\
HOSTNAME=<hostname> ;\
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> ;\
LIVEURL=<liveurl> ;\
HOSTNAME=<hostname> ;\
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> ;\
HOSTNAME=<hostname> ;\
ytpodgen --title ${TITLE} --hostname ${HOSTNAME}
```

This generates `index.rss` file under current directory and exits.

## 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


## TODO
- [x] use `boto3` for uploading files in order to remove `rclone`
- [x] generate rss feed with python code in order to remove `dropcaster`
- [x] embed `yt-dlp` into ytpodgen, instead of calling it via docker
- [x] use `--live-from-start` option for yt-dlp if the stream has already started
- [x] package this app using `poetry` so that I can install this using `pip`
- [x] introduce [Click](https://click.palletsprojects.com/en/8.0.x/) for this project
