Skip to content

Commit

Permalink
Merge pull request #250 from madiele/main
Browse files Browse the repository at this point in the history
New release to fix outdated yt-dlp
  • Loading branch information
madiele authored Jan 27, 2025
2 parents ca424c9 + 2ce2f4a commit 202c09f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 26 deletions.
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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==2024.8.1
yt-dlp==2025.1.15
6 changes: 5 additions & 1 deletion src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum ConfName {
ValidUrlDomains,
AudioCodec,
PeerTubeValidHosts,
YouutbeYtDlpExtraArgs,
}

struct EnvConf {}
Expand Down Expand Up @@ -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()))
}
}
}
}
Expand Down Expand Up @@ -165,4 +170,3 @@ impl Default for AudioCodec {
Self::MP3
}
}

37 changes: 28 additions & 9 deletions src/provider/youtube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,20 @@ fn get_youtube_hub() -> YouTube<hyper_rustls::HttpsConnector<hyper::client::Http
)]
async fn get_youtube_stream_url(url: &Url) -> eyre::Result<Url> {
debug!("getting stream_url for yt video: {}", url);
let output = tokio::process::Command::new("yt-dlp")
let extra_args: Vec<String> =
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) => {
Expand All @@ -494,9 +501,10 @@ async fn get_youtube_stream_url(url: &Url) -> eyre::Result<Url> {
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))
}
Expand Down Expand Up @@ -564,8 +572,20 @@ async fn find_yt_channel_url_with_c_id(url: &Url) -> eyre::Result<Url> {
.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, Option<usize>>) -> String {
Expand Down Expand Up @@ -805,4 +825,3 @@ mod tests {
}
}
}

0 comments on commit 202c09f

Please sign in to comment.