refactored player

This commit is contained in:
ThetaDev 2022-09-13 15:44:50 +02:00
parent 6cc927031a
commit 925652acdd
11 changed files with 1102 additions and 107 deletions

View file

@ -3,11 +3,9 @@ name = "rustypipe-cli"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rustypipe = {path = "../"}
reqwest = {version = "0.11.11", default_features = false, features = ["gzip", "brotli", "rustls-tls-native-roots"]}
rustypipe = {path = "../", default_features = false, features = ["rustls-tls-native-roots"]}
reqwest = {version = "0.11.11", default_features = false}
tokio = {version = "1.20.0", features = ["rt-multi-thread"]}
indicatif = "0.17.0"
futures = "0.3.21"

View file

@ -6,7 +6,7 @@ use futures::stream::{self, StreamExt};
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use reqwest::{Client, ClientBuilder};
use rustypipe::{
client::{ClientType, RustyTube},
client2::{ClientType, RustyPipe},
model::stream_filter::Filter,
};
@ -46,7 +46,7 @@ async fn download_single_video(
output_fname: Option<String>,
resolution: Option<u32>,
ffmpeg: &str,
rt: &RustyTube,
rp: &RustyPipe,
http: Client,
multi: MultiProgress,
main: Option<ProgressBar>,
@ -58,7 +58,7 @@ async fn download_single_video(
pb.set_message(format!("Fetching player data for {}", video_title));
let res = async {
let player_data = rt
let player_data = rp
.get_player(video_id.as_str(), ClientType::TvHtml5Embed)
.await
.context(format!(
@ -112,7 +112,7 @@ async fn download_video(
.build()
.expect("unable to build the HTTP client");
let rt = RustyTube::new();
let rp = RustyPipe::default();
// Indicatif setup
let multi = MultiProgress::new();
@ -124,7 +124,7 @@ async fn download_video(
output_fname,
resolution,
"ffmpeg",
&rt,
&rp,
http,
multi,
None,
@ -147,8 +147,8 @@ async fn download_playlist(
.build()
.expect("unable to build the HTTP client");
let rt = RustyTube::new();
let playlist = rt.get_playlist(id).await.unwrap();
let rp = RustyPipe::default();
let playlist = rp.get_playlist(id).await.unwrap();
// Indicatif setup
let multi = MultiProgress::new();
@ -173,7 +173,7 @@ async fn download_playlist(
output_fname.to_owned(),
resolution,
"ffmpeg",
&rt,
&rp,
http.clone(),
multi.clone(),
Some(main.clone()),