GyrosOfWar / youtube-dl-rs

A youtube-dl wrapper for Rust
132 stars 40 forks source link

`downloader` Feature Requires `native-tls` #48

Open onkoe opened 1 year ago

onkoe commented 1 year ago

I'd really like to use the downloader feature for usage of the download_yt_dlp function, but it seems that you can't use the downloader without native-tls enabled, too!

I tried changing out the features with this patch:

From c911b5ea2b0cefd1b2ce5b9d57bc5252f1128930 Mon Sep 17 00:00:00 2001
From: ...
Date: ...
Subject: [PATCH] Switched to rustls-tls feature by default

---
 Cargo.toml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index ad40ae5..4c96935 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,8 +11,8 @@ categories = ["multimedia::video"]
 keywords = ["youtube-dl", "youtube", "yt-dlp"]

 [features]
-default = ["native-tls"]
-downloader = ["reqwest", "tokio", "native-tls"]
+default = ["rustls-tls"]
+downloader = ["reqwest", "tokio", "rustls-tls"]
 native-tls = ["reqwest/native-tls"]
 rustls-tls = ["reqwest/rustls-tls"]

-- 
2.40.1

I then ran the tests using cargo test --all, with all of them succeeding. It seems that it's not on purpose to require native TLS implementations for downloading the yt-dlp application.

To ensure that the library still worked fine for binaries, I also dumped some basic code into a new Rust project:

[package]
name = "test-me"
version = "0.1.0"
edition = "2021"

[dependencies]
youtube_dl = {path = "/home/barrett/Downloads/youtube-dl-rs", features = ["downloader"]}
tokio = { version = "1.28", features = ["rt", "rt-multi-thread", "macros"] }
#[tokio::main]
async fn main() {
    println!("Hello, world!");
    dbg!(youtube_dl::download_yt_dlp(std::path::PathBuf::from("./")).await);
}

Running this binary project returns a working yt-dlp binary, as expected.

Is there any reason to not loosen these requirements? To my knowledge, there's no way to require the use of one or both, so you could either #[cfg] up the source, or add two different download feature set types in Cargo.toml, like download and download-rustls.

Many thanks, Barrett

GyrosOfWar commented 1 year ago

Hey, no, that's an oversight on my part. I'll fix that.

onkoe commented 1 year ago

I’m super happy to hear that!!

Thanks for your hard work on this library so far! (;

GyrosOfWar commented 1 year ago

@onkoe I've split the downloader feature into downloader-native-tls and downloader-rustls-tls features with the new version (0.9.0). Those should work better than what was there before. Let me know if it works when you get around to it.