Skip to content

Commit

Permalink
07.07.2024
Browse files Browse the repository at this point in the history
* `socks` and `native-tls-vendored` feature flags added
  • Loading branch information
Mithronn committed Jul 7, 2024
1 parent 097bc9b commit 6df29b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ members = [".", "cli"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = { version = "0.12.4", features = [
reqwest = { version = "0.12.5", features = [
"cookies",
"gzip",
], default-features = false }
Expand All @@ -39,8 +39,8 @@ derivative = "2.2.0"
once_cell = "1.19.0"
tokio = { version = "1.37.0", default-features = false, features = ["sync"] }
rand = "0.8.5"
reqwest-middleware = { version = "0.3.1", features = ["json"] }
reqwest-retry = "0.5.0"
reqwest-middleware = { version = "0.3.2", features = ["json"] }
reqwest-retry = "0.6.0"
m3u8-rs = "6.0.0"
async-trait = "0.1.80"
aes = "0.8.4"
Expand All @@ -65,6 +65,8 @@ ffmpeg = ["tokio/process", "tokio/io-util"]
default-tls = ["reqwest/default-tls"]
native-tls = ["reqwest/native-tls"]
rustls-tls = ["reqwest/rustls-tls"]
native-tls-vendored = ["reqwest/native-tls-vendored"]
socks = ["reqwest/socks"]

[[example]]
name = "multiple_downloads"
Expand Down
12 changes: 4 additions & 8 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,32 +128,28 @@ impl Video {
.filter(|x| x.inner_html().contains("var ytInitialPlayerResponse ="))
.map(|x| x.inner_html().replace("var ytInitialPlayerResponse =", ""))
.next()
.unwrap_or(String::from(""))
.trim()
.to_string();
.unwrap_or(String::from(""));
let mut initial_response_string = document
.select(&scripts_selector)
.filter(|x| x.inner_html().contains("var ytInitialData ="))
.map(|x| x.inner_html().replace("var ytInitialData =", ""))
.next()
.unwrap_or(String::from(""))
.trim()
.to_string();
.unwrap_or(String::from(""));

// remove json object last element (;)
initial_response_string.pop();

let player_response = serde_json::from_str::<PlayerResponse>(
format!(
"{{{}}}}}}}",
between(player_response_string.as_str(), "{", "}}};")
between(player_response_string.trim(), "{", "}}};")
)
.as_str(),
)
.unwrap();

let initial_response =
serde_json::from_str::<serde_json::Value>(&initial_response_string).unwrap();
serde_json::from_str::<serde_json::Value>(initial_response_string.trim()).unwrap();

(player_response, initial_response)
};
Expand Down

0 comments on commit 6df29b9

Please sign in to comment.