Skip to content

Commit

Permalink
Merge pull request #169 from madiele/main
Browse files Browse the repository at this point in the history
update dependencies
  • Loading branch information
madiele authored May 5, 2024
2 parents cfb36e8 + fda8647 commit 1043a9d
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 106 deletions.
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"image": "mcr.microsoft.com/devcontainers/rust:latest",
"postCreateCommand": "./.devcontainer/PostCreateScript.sh",
"postStartCommand": "make start-deps",
"customizations": {
Expand All @@ -10,5 +10,8 @@
"ms-azuretools.vscode-docker"
]
}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": "latest"
}
}
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ path = "src/main.rs"

[dependencies]
actix-rt = "=2.9.0"
google-youtube3 = "=5.0.3"
google-youtube3 = "=5.0.4"
actix-web = "=4.5.1"
async-trait = "=0.1.77"
async-trait = "=0.1.80"
url = { version="=2.5.0", features = ["serde"]}
futures = "=0.3.30"
log = "=0.4.20"
regex = "=1.10.3"
reqwest = { version = "=0.11.24", features = ["json"] }
serde = "=1.0.197"
serde_json = "=1.0.114"
tokio = { version = "=1.36.0", features = ["macros", "process"]}
uuid = { version= "=1.7.0", features = ["v4", "serde"]}
log = "=0.4.21"
regex = "=1.10.4"
reqwest = { version = "=0.12.4", features = ["json"] }
serde = "=1.0.199"
serde_json = "=1.0.116"
tokio = { version = "=1.37.0", features = ["macros", "process"]}
uuid = { version= "=1.8.0", features = ["v4", "serde"]}
genawaiter = {version = "=0.99", features = ["futures03"] }
openssl = { version = "*", features = ["vendored"] } #this is here just to make cross-compiling work during github actions
rss = { version = "=2.0", features = ["serde"] }
eyre = "=0.6"
simple_logger = "=4.3"
redis = { version = "=0.24", features = ["tokio-comp"] }
redis = { version = "=0.25", features = ["tokio-comp"] }
mime = "=0.3.17"
cached = { version = "=0.49.2", features = ["redis_tokio"] }
cached = { version = "=0.50.0", features = ["redis_tokio"] }
iso8601-duration = "=0.2.0"
chrono = "=0.4.34"
chrono = "=0.4.38"
feed-rs = "=1.4.0"

[dev-dependencies]
Expand Down
161 changes: 75 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,95 @@
# vod2pod-rss [![tests](https://github.com/madiele/vod2pod-rss/actions/workflows/rust.yml/badge.svg)](https://github.com/madiele/vod2pod-rss/actions/workflows/rust.yml) [![stable image](https://github.com/madiele/vod2pod-rss/actions/workflows/docker-image.yml/badge.svg?branch=stable)](https://github.com/madiele/vod2pod-rss/actions/workflows/docker-image.yml) [![beta image](https://github.com/madiele/vod2pod-rss/actions/workflows/docker-image-beta.yml/badge.svg)](https://github.com/madiele/vod2pod-rss/actions/workflows/docker-image-beta.yml)

Converts a YouTube or Twitch channel into a full-blown podcast.
Converts a YouTube or Twitch channel into a full blown audio podcast feed.

<a label="example of it working with podcast addict" href="https://user-images.githubusercontent.com/4585690/231301791-2f838fb3-4f6e-4382-bac4-c968bfe98c08.png"><img src="https://user-images.githubusercontent.com/4585690/231301791-2f838fb3-4f6e-4382-bac4-c968bfe98c08.png" align="left" height="350" ></a>

## Features
<a label="example of it working with podcast addict" href="https://user-images.githubusercontent.com/4585690/231301791-2f838fb3-4f6e-4382-bac4-c968bfe98c08.png"><img src="https://user-images.githubusercontent.com/4585690/231301791-2f838fb3-4f6e-4382-bac4-c968bfe98c08.png" align="right" height="350" ></a>

# Features
- Completely converts the VoDs into a proper podcast RSS that can be listened to directly inside the client.
- The VoDs are not downloaded on the server, so no need for storage while self-hosting this app.
- VoDs are transcoded to MP3 192k on the fly by default, tested to be working flawlessly even on a Raspberry Pi 3-4.
- also works on standard rss podcasts feed if you want to have a lower bitrate version to save mobile data.

## Limitations
- Youtube channel avatar is not present and results are limited to 15 when no YouTube API key is set.

- Youtube channel avatar is not present and results are limited to 15 when no youtube API key is set

## Usage
# Usage

## Web UI
<a label="frontend" href="https://user-images.githubusercontent.com/4585690/234704870-0bf3023a-78e0-4ccc-adea-9d1f6ea2fabc.png"><img src="https://user-images.githubusercontent.com/4585690/234704870-0bf3023a-78e0-4ccc-adea-9d1f6ea2fabc.png" align="right" width="400px" ></a>

Just go to the root of the server es: `myserver.com` and paste the channel you want to convert to podcast and copy the generated link.

you can also build the url manually just add `/transcodize_rss?url=channel_url` to your server path, and an RSS will be generated. Replace `channel_url` with the URL of the YouTube or Twitch channel you want to convert into a podcast.

Example youtube: `myserver.com/transcodize_rss?url=https://www.youtube.com/c/channelname`

Example twitch: `myserver.com/transcodize_rss?url=https://www.twitch.tv/channelname`

Example rss/atom feed (be sure to add the domain to the whitelist): `myserver.com/transcodize_rss?url=https://feeds.simplecast.com/aU_RzZ7j`

Just add the link to your podcast client.

## Installation

### install with docker

### twitch support (optional)

get your SECRET and CLIENT ID from twitch

<https://dev.twitch.tv/console>

### better youtube support (optional)

only needed if you want youtube channels avatar and better playlist support

get your youtube api key here

<https://developers.google.com/youtube/v3/getting-started>

### running the server

precompiled images are [here](https://hub.docker.com/r/madiele/vod2pod-rss/) for linux machines with arm64, amd64 and armv7 (raspberry pis are supported).

#### use [docker compose](https://docs.docker.com/compose/install/) with precompiled image

`git clone https://github.com/madiele/vod2pod-rss.git`

`cd vod2pod-rss`

edit `docker-compose.yml` with your SECRET and CLIENT_ID for youtube and twitch if needed
(in the file you will find also optional parameters like bitrate).

If you host other stuff on you machine you might want to change the host port from 80 to something else:

es: to change the host port to 1234 edit `- "80:8080"` to `- "1234:8080"`

to edit the file do

`nano docker-compose.yml`

save and

`sudo docker compose up -d`

#### new releases notifications

To get notifications of new release be sure to watch the repo and set a custom notification only on new releases.

#### when you want to update

run this inside the folder with `docker-compose.yml`

`sudo docker compose pull && sudo docker compose up -d`

then run this to delete the old version from your system (note: this will also delete any other unused image you have)

`sudo docker system prune`

## Configuration

You can set the following environment variables:

- `TRANSCODE`: Set to "false" to disable transcoding, usefull if you only need the feeds (default: "false")
- just go where you hosted vod2pod and you will find an easy to use UI to generate the feed
## Manually Generate A Podcast URL
- In a web browser go to where you hosted vod2pod, es: http://myserver.com/ or http://localhost/
- In the web page that opens paste the channel you want to convert to podcast and copy the generated link.
- Optionally goto : http://myserver.com/transcodize_rss?url=channel_url
- An RSS will be generated.
- Replace `channel_url` with the URL of the YouTube or Twitch channel you want to convert into a podcast.
- YouTube: `http://myserver.com/transcodize_rss?url=https://www.youtube.com/c/channelname`
- Twitch: `http://myserver.com/transcodize_rss?url=https://www.twitch.tv/channelname`
- RSS/atom feed: `http://myserver.com/transcodize_rss?url=https://feeds.simplecast.com/aU_RzZ7j`
- Add the domain to the whitelist. See configurations [below](#configurations)

## Add The URL To A Podcast Client
- find a tutorial on how to add an rss feed to your favorite podcast app

# Optional API Access
- Twitch: Get your SECRET and CLIENT ID <https://dev.twitch.tv/console>
- YouTube: Enable more than 15 items in the RSS feed, channel avatar
- API key <https://developers.google.com/youtube/v3/getting-started>
- Enable API Access <https://console.cloud.google.com/>
- APIs & Services > +Enable APIs and Services > Search "YouTube Data API"

See configurations [below](#configurations)

# Install
## Clone This Repository
```
git clone https://github.com/madiele/vod2pod-rss.git
```

## Docker
- Install [Docker Compose](https://docs.docker.com/compose/install/)
- Precompiled images are available [here](https://hub.docker.com/r/madiele/vod2pod-rss/) for linux machines with arm64, amd64 and armv7 (raspberry pis are supported).

### Docker Compose
```
cd vod2pod-rss
nano docker-compose.yml
```
See configurations [below](#configurations)
```
sudo docker compose up -d
```

#### Updating
```
sudo docker compose pull && sudo docker compose up -d
sudo docker system prune
```
- To get notifications of new release follow [these instructions](https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/about-notifications)

## Configurations
### Web Server Port
- `ports`: "80:8080" (optional) Change 80 to another port if you already use the port 80 on your host
- e.g. "81:8080" http://myserver.com:81/

### Optional API Keys
- `YT_API_KEY`: Set your YouTube API key (works without but the feed is limited to 15)
- e.g. YT_API_KEY=AIzaSyBTCCEOHm
- `TWITCH_SECRET`: Set your Twitch secret
- `TWITCH_CLIENT_ID`: Set your Twitch client ID

Note: These can also be set using Docker [.env files](https://docs.docker.com/compose/environment-variables/env-file/)

### Environment
- `TRANSCODE`: Set to "false" to disable transcoding, usefull if you only need the feeds (default: "true")
- `MP3_BITRATE`: Set the bitrate of the trascoded stream to your client (default: "192")
- `SUBFOLDER`: Set the the root path of the app, useful for reverse proxies (default: "/")
- `VALID_URL_DOMAINS`: (optional) Set a comma separated list of domains urls that are allowed to be converted into RSS (defaults to yotube and twitch urls)
- `VALID_URL_DOMAINS`: (optional) Set a comma separated list of domain urls that are allowed to be converted into RSS (defaults to YouTube and Twitch urls)

## Honorable mentions
# Honorable Mentions

This projects were fondamental for the success of vod2pod-rss, originally they handled the feed generation for youtube and twitch, now this is all done by vod2pod-rss internally so they are not used anymore, but were still helpful to get vod2pod-rss up and running fast.
Those project were:
These projects were fundamental for the success of vod2pod-rss, originally they handled the feed generation for youtube and twitch, now this is all done by vod2pod-rss internally so they are not used anymore, but were still helpful to get vod2pod-rss up and running fast.
* Youtube support was possible thanks to the cool [podtube fork project by amckee](https://github.com/amckee/PodTube) consider dropping him a star.
* Twitch support was possible thanks to [my fork](https://github.com/madiele/TwitchToPodcastRSS) of [lzeke0's TwitchRSS](https://github.com/lzeke0/TwitchRSS) drop a star to him too!

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# this is only used to track the version in the Dockerfile and with depend-a-bot
yt-dlp==2023.12.30
yt-dlp==2024.4.9
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pub mod rss_transcodizer;
pub mod server;
pub mod transcoder;

pub async fn get_redis_client() -> Result<redis::aio::Connection, eyre::Error> {
pub async fn get_redis_client() -> Result<redis::aio::MultiplexedConnection, eyre::Error> {
let redis_address = conf().get(ConfName::RedisAddress).unwrap();
let redis_port = conf().get(ConfName::RedisPort).unwrap();
let client = redis::Client::open(format!("redis://{}:{}/", redis_address, redis_port))?;
let con = client.get_tokio_connection().await?;
let con = client.get_multiplexed_tokio_connection().await?;
Ok(con)
}

8 changes: 4 additions & 4 deletions src/provider/youtube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ struct VideoExtraInfo {
}

async fn create_duration_url_map(
items: &Vec<PlaylistItem>,
items: &[PlaylistItem],
api_key: &str,
) -> Result<HashMap<String, VideoExtraInfo>, eyre::Error> {
let ids_batches = items.chunks(50).map(|c| {
Expand Down Expand Up @@ -467,7 +467,7 @@ fn get_youtube_hub() -> YouTube<hyper_rustls::HttpsConnector<hyper::client::Http

#[io_cached(
map_error = r##"|e| eyre::Error::new(e)"##,
type = "AsyncRedisCache<Url, Url>",
ty = "AsyncRedisCache<Url, Url>",
create = r##" {
AsyncRedisCache::new("cached_yt_stream_url=", 18000)
.set_refresh(false)
Expand Down Expand Up @@ -543,7 +543,7 @@ async fn feed_url_for_yt_channel(url: &Url) -> eyre::Result<Url> {
not(test),
io_cached(
map_error = r##"|e| eyre::Error::new(e)"##,
type = "AsyncRedisCache<Url, Url>",
ty = "AsyncRedisCache<Url, Url>",
create = r##" {
AsyncRedisCache::new("youtube_channel_username_to_id=", 9999999)
.set_refresh(false)
Expand Down Expand Up @@ -627,7 +627,7 @@ fn convert_atom_to_rss(feed: Feed, duration_map: HashMap<String, Option<usize>>)
not(test),
io_cached(
map_error = r##"|e| eyre::Error::new(e)"##,
type = "AsyncRedisCache<Url, Option<usize>>",
ty = "AsyncRedisCache<Url, Option<usize>>",
create = r##" {
AsyncRedisCache::new("cached_yt_video_duration=", 86400)
.set_refresh(false)
Expand Down

0 comments on commit 1043a9d

Please sign in to comment.