mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Update dependencies
This commit is contained in:
parent
474e9f5e31
commit
6aa4078be3
6 changed files with 342 additions and 92 deletions
|
|
@ -387,7 +387,7 @@ async fn download_video(ctx: &Context, format: &Format, only_audio: bool) -> Res
|
|||
ctx,
|
||||
&mut ffmpeg.stdin.unwrap(),
|
||||
Some(format!("Download {}", format.audio)),
|
||||
format.stream.segments().await?,
|
||||
format.stream.clone()
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::utils::parse::{parse_url, UrlFilter};
|
|||
use crate::utils::sort::{sort_formats_after_seasons, sort_seasons_after_number};
|
||||
use crate::Execute;
|
||||
use anyhow::{bail, Result};
|
||||
use crunchyroll_rs::media::{Resolution, VariantSegment};
|
||||
use crunchyroll_rs::media::{Resolution, VariantData};
|
||||
use crunchyroll_rs::{
|
||||
Episode, Locale, Media, MediaCollection, Movie, MovieListing, Season, Series,
|
||||
};
|
||||
|
|
@ -212,16 +212,14 @@ impl Execute for Download {
|
|||
tab_info!("Resolution: {}", format.stream.resolution);
|
||||
tab_info!("FPS: {:.2}", format.stream.fps);
|
||||
|
||||
let segments = format.stream.segments().await?;
|
||||
|
||||
if use_ffmpeg {
|
||||
download_ffmpeg(&ctx, segments, path.as_path()).await?;
|
||||
download_ffmpeg(&ctx, format.stream, path.as_path()).await?;
|
||||
} else if path.to_str().unwrap() == "-" {
|
||||
let mut stdout = std::io::stdout().lock();
|
||||
download_segments(&ctx, &mut stdout, None, segments).await?;
|
||||
download_segments(&ctx, &mut stdout, None, format.stream).await?;
|
||||
} else {
|
||||
let mut file = File::options().create(true).write(true).open(&path)?;
|
||||
download_segments(&ctx, &mut file, None, segments).await?
|
||||
download_segments(&ctx, &mut file, None, format.stream).await?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -232,7 +230,7 @@ impl Execute for Download {
|
|||
|
||||
async fn download_ffmpeg(
|
||||
ctx: &Context,
|
||||
segments: Vec<VariantSegment>,
|
||||
variant_data: VariantData,
|
||||
target: &Path,
|
||||
) -> Result<()> {
|
||||
let ffmpeg = Command::new("ffmpeg")
|
||||
|
|
@ -246,7 +244,7 @@ async fn download_ffmpeg(
|
|||
.arg(target.to_str().unwrap())
|
||||
.spawn()?;
|
||||
|
||||
download_segments(ctx, &mut ffmpeg.stdin.unwrap(), None, segments).await?;
|
||||
download_segments(ctx, &mut ffmpeg.stdin.unwrap(), None, variant_data).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,15 @@ pub fn find_resolution(
|
|||
}
|
||||
|
||||
pub async fn download_segments(
|
||||
ctx: &Context,
|
||||
_ctx: &Context,
|
||||
writer: &mut impl Write,
|
||||
message: Option<String>,
|
||||
segments: Vec<VariantSegment>,
|
||||
variant_data: VariantData,
|
||||
) -> Result<()> {
|
||||
let segments = variant_data.segments().await?;
|
||||
let total_segments = segments.len();
|
||||
|
||||
let client = Arc::new(ctx.client.clone());
|
||||
let client = Arc::new(variant_data.download_client());
|
||||
let count = Arc::new(Mutex::new(0));
|
||||
let amount = Arc::new(Mutex::new(0));
|
||||
|
||||
|
|
|
|||
|
|
@ -170,29 +170,7 @@ pub async fn cli_entrypoint() {
|
|||
|
||||
async fn create_ctx(cli: &Cli) -> Result<Context> {
|
||||
let crunchy = crunchyroll_session(cli).await?;
|
||||
// use crunchy.client() when it's possible
|
||||
// currently crunchy.client() has a cloudflare bypass built-in to access crunchyroll. the servers
|
||||
// where crunchy stores their videos can't handle this bypass and simply refuses to connect
|
||||
#[cfg(not(all(windows, target_env = "msvc")))]
|
||||
let client = isahc::HttpClient::new().unwrap();
|
||||
#[cfg(all(windows, target_env = "msvc"))]
|
||||
use isahc::config::Configurable;
|
||||
#[cfg(all(windows, target_env = "msvc"))]
|
||||
let client = isahc::HttpClientBuilder::default()
|
||||
.tls_config(
|
||||
isahc::tls::TlsConfigBuilder::default()
|
||||
.root_cert_store(isahc::tls::RootCertStore::custom(
|
||||
rustls_native_certs::load_native_certs()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|l| isahc::tls::Certificate::from_der(l.0)),
|
||||
))
|
||||
.build(),
|
||||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
Ok(Context { crunchy, client })
|
||||
Ok(Context { crunchy })
|
||||
}
|
||||
|
||||
async fn crunchyroll_session(cli: &Cli) -> Result<Crunchyroll> {
|
||||
|
|
|
|||
|
|
@ -2,5 +2,4 @@ use crunchyroll_rs::Crunchyroll;
|
|||
|
||||
pub struct Context {
|
||||
pub crunchy: Crunchyroll,
|
||||
pub client: isahc::HttpClient,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue