mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Add proxy flag (#142)
This commit is contained in:
parent
5f98cfb186
commit
d33e2fa36b
4 changed files with 47 additions and 5 deletions
|
|
@ -9,7 +9,7 @@ anyhow = "1.0"
|
|||
async-trait = "0.1"
|
||||
clap = { version = "4.2", features = ["derive", "string"] }
|
||||
chrono = "0.4"
|
||||
crunchyroll-rs = { version = "0.3", features = ["dash-stream"] }
|
||||
crunchyroll-rs = { version = "0.3.3", features = ["dash-stream"] }
|
||||
ctrlc = "3.2"
|
||||
dirs = "5.0"
|
||||
derive_setters = "0.1"
|
||||
|
|
@ -19,6 +19,7 @@ lazy_static = "1.4"
|
|||
log = { version = "0.4", features = ["std"] }
|
||||
num_cpus = "1.15"
|
||||
regex = "1.7"
|
||||
reqwest = { version = "0.11", features = ["socks"] }
|
||||
sanitize-filename = "0.4"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ use crate::utils::log::{progress, CliLogger};
|
|||
use anyhow::bail;
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, Subcommand};
|
||||
use crunchyroll_rs::crunchyroll::CrunchyrollBuilder;
|
||||
use crunchyroll_rs::{Crunchyroll, Locale};
|
||||
use log::{debug, error, warn, LevelFilter};
|
||||
use reqwest::Proxy;
|
||||
use std::{env, fs};
|
||||
|
||||
mod archive;
|
||||
|
|
@ -50,6 +52,14 @@ pub struct Cli {
|
|||
#[clap(flatten)]
|
||||
login_method: LoginMethod,
|
||||
|
||||
#[arg(help = "Use a proxy to route all traffic through")]
|
||||
#[arg(long_help = "Use a proxy to route all traffic through. \
|
||||
Make sure that the proxy can either forward TLS requests, which is needed to bypass the (cloudflare) bot protection, or that it is configured so that the proxy can bypass the protection itself"
|
||||
)]
|
||||
#[clap(long)]
|
||||
#[arg(value_parser = crate::utils::clap::clap_parse_proxy)]
|
||||
proxy: Option<Proxy>,
|
||||
|
||||
#[clap(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
|
@ -234,7 +244,13 @@ async fn crunchyroll_session(cli: &Cli) -> Result<Crunchyroll> {
|
|||
lang
|
||||
};
|
||||
|
||||
let mut client_builder = CrunchyrollBuilder::predefined_client_builder();
|
||||
if let Some(proxy) = &cli.proxy {
|
||||
client_builder = client_builder.proxy(proxy.clone())
|
||||
}
|
||||
|
||||
let mut builder = Crunchyroll::builder()
|
||||
.client(client_builder.build()?)
|
||||
.locale(locale)
|
||||
.stabilization_locales(cli.experimental_fixes)
|
||||
.stabilization_season_number(cli.experimental_fixes);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
use crate::utils::parse::parse_resolution;
|
||||
use crunchyroll_rs::media::Resolution;
|
||||
use reqwest::Proxy;
|
||||
|
||||
pub fn clap_parse_resolution(s: &str) -> Result<Resolution, String> {
|
||||
parse_resolution(s.to_string()).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
pub fn clap_parse_proxy(s: &str) -> Result<Proxy, String> {
|
||||
Proxy::all(s).map_err(|e| e.to_string())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue