diff --git a/Cargo.toml b/Cargo.toml index fcfa0c8..cdf25b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,28 +14,28 @@ path = "src/main.rs" [dependencies] actix-rt = "=2.10.0" google-youtube3 = "=5.0.4" -actix-web = "=4.8.0" -async-trait = "=0.1.81" -url = { version="=2.5.2", features = ["serde"]} -futures = "=0.3.30" -log = "=0.4.22" -regex = "=1.10.5" -reqwest = { version = "=0.12.5", features = ["json"] } -serde = "=1.0.204" -serde_json = "=1.0.121" -tokio = { version = "=1.39.2", features = ["macros", "process"]} -uuid = { version= "=1.10.0", features = ["v4", "serde"]} +actix-web = "=4.9.0" +async-trait = "=0.1.85" +url = { version="=2.5.4", features = ["serde"]} +futures = "=0.3.31" +log = "=0.4.25" +regex = "=1.11.1" +reqwest = { version = "=0.12.12", features = ["json"] } +serde = "=1.0.217" +serde_json = "=1.0.137" +tokio = { version = "=1.43.0", features = ["macros", "process"]} +uuid = { version= "=1.12.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 = "=5.0" -redis = { version = "=0.26", features = ["tokio-comp"] } +redis = { version = "=0.28", features = ["tokio-comp"] } mime = "=0.3.17" -cached = { version = "=0.53.1", features = ["redis_tokio"] } +cached = { version = "=0.54.0", features = ["redis_tokio"] } iso8601-duration = "=0.2.0" -chrono = "=0.4.38" -feed-rs = "=2.1.0" +chrono = "=0.4.39" +feed-rs = "=2.3.1" [dev-dependencies] temp-env ={ version = "=0.3.6", features = ["async_closure"] } diff --git a/README.md b/README.md index e7b5441..4624ecf 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,14 @@ 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) +#### Switching to the Beta branch + +The beta branch is a version of vod2pod that is always updated to the latest yt-dlp releases in a matter of days, if you have problems try it out first to see if they are fixed, then open an issue so that I can consider making a new stable release + +Also by being on the beta branch you might help me find bugs before I make any new stable release, so you'll help the project too + +To switch open the compose docker-compose.yml and edit the vod2pod image section from "latest" to "beta", then follow the steps to update + ## Configurations ### Web Server Port - `ports`: "80:8080" (optional) Change 80 to another port if you already use the port 80 on your host diff --git a/requirements.txt b/requirements.txt index c76739a..02a11ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ # this is only used to track the version in the Dockerfile and with depend-a-bot -yt-dlp==2024.8.1 +yt-dlp==2025.1.15 diff --git a/src/configs/mod.rs b/src/configs/mod.rs index 02aff54..6b4a7d3 100644 --- a/src/configs/mod.rs +++ b/src/configs/mod.rs @@ -23,6 +23,7 @@ pub enum ConfName { ValidUrlDomains, AudioCodec, PeerTubeValidHosts, + YouutbeYtDlpExtraArgs, } struct EnvConf {} @@ -106,6 +107,10 @@ impl Conf for EnvConf { ConfName::YouutbeMaxResults => { Ok(std::env::var("YOUTUBE_MAX_RESULTS").unwrap_or_else(|_| "300".to_string())) } + ConfName::YouutbeYtDlpExtraArgs => { + Ok(std::env::var("YOUTUBE_YT_DLP_GET_URL_EXTRA_ARGS") + .unwrap_or_else(|_| "[]".to_string())) + } } } } @@ -165,4 +170,3 @@ impl Default for AudioCodec { Self::MP3 } } - diff --git a/src/provider/youtube.rs b/src/provider/youtube.rs index 8d9f709..7753edb 100644 --- a/src/provider/youtube.rs +++ b/src/provider/youtube.rs @@ -479,13 +479,20 @@ fn get_youtube_hub() -> YouTube eyre::Result { debug!("getting stream_url for yt video: {}", url); - let output = tokio::process::Command::new("yt-dlp") + let extra_args: Vec = + serde_json::from_str(conf().get(ConfName::YouutbeYtDlpExtraArgs)?.as_str()).map_err(|_| eyre!(r#"failed to parse YOUTUBE_YT_DLP_GET_URL_EXTRA_ARGS allowed syntax is ["arg1#", "arg2", "arg3", ...]"#))?; + let mut command = tokio::process::Command::new("yt-dlp"); + command .arg("-f") .arg("bestaudio") .arg("--get-url") - .arg(url.as_str()) - .output() - .await; + .arg(url.as_str()); + + for arg in extra_args { + command.arg(arg); + } + + let output = command.output().await; match output { Ok(x) => { @@ -494,9 +501,10 @@ async fn get_youtube_stream_url(url: &Url) -> eyre::Result { Ok(url) => Ok(url), Err(e) => { warn!( - "error while parsing stream url:\ninput: {}\nerror: {}", + "error while parsing stream url using yt-dlp:\nerror: {}\nyt-dlp stdout: {}\nyt-dlp stderr: {}", + e.to_string(), raw_url, - e.to_string() + std::str::from_utf8(&x.stderr).unwrap_or_default() ); Err(eyre::eyre!(e)) } @@ -564,8 +572,20 @@ async fn find_yt_channel_url_with_c_id(url: &Url) -> eyre::Result { .arg(url.to_string()) .output() .await?; - let feed_url = std::str::from_utf8(&output.stdout)?.trim().to_string(); - Ok(Url::parse(&feed_url)?) + let conversion = std::str::from_utf8(&output.stdout); + let feed_url = match conversion { + Ok(feed_url) => feed_url, + Err(e) => { + warn!( + "error while translating channel name using yt-dlp:\nerror: {}\nyt-dlp stdout: {}\nyt-dlp stderr: {}", + e.to_string(), + conversion.unwrap_or_default(), + std::str::from_utf8(&output.stderr).unwrap_or_default() + ); + return Err(eyre::eyre!(e)); + } + }; + Ok(Url::parse(feed_url)?) } fn convert_atom_to_rss(feed: Feed, duration_map: HashMap>) -> String { @@ -805,4 +825,3 @@ mod tests { } } } -