Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: add Accept-Language header for proper dublang
Browse files Browse the repository at this point in the history
  • Loading branch information
khyerdev committed May 1, 2024
1 parent 2d98fdc commit 4a596ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct Args {
pub c_tt_h265: bool,
pub c_dublang: bool,
pub c_disable_metadata: bool,
pub accept_language: String,
pub out_filename: Option<String>,
pub c_fname_style: types::FilenamePattern,
pub same_filenames: bool,
Expand Down Expand Up @@ -48,6 +49,7 @@ impl Args {
c_tt_h265: false,
c_dublang: false,
c_disable_metadata: false,
accept_language: String::from("en")
}
}

Expand Down Expand Up @@ -94,7 +96,10 @@ impl Args {
"--twitter-gif" => self.c_twitter_gif = true,
"--tt-full-audio" => self.c_tt_full_audio = true,
"--tt-h265" => self.c_tt_h265 = true,
"--dublang" => self.c_dublang = true,
"--dublang" => {
self.c_dublang = true;
expected.push(ExpectedFlags::Language);
},
"--no-metadata" => self.c_disable_metadata = true,
"--output" => expected.push(ExpectedFlags::Output),
"--fname-style" => expected.push(ExpectedFlags::FilenamePattern),
Expand Down Expand Up @@ -127,7 +132,10 @@ impl Args {
'g' => self.c_twitter_gif = true,
'u' => self.c_tt_full_audio = true,
'h' => self.c_tt_h265 = true,
'l' => self.c_dublang = true,
'l' => {
self.c_dublang = true;
expected.push(ExpectedFlags::Language);
},
'n' => self.c_disable_metadata = true,
'o' => expected.push(ExpectedFlags::Output),
's' => expected.push(ExpectedFlags::FilenamePattern),
Expand Down Expand Up @@ -185,6 +193,9 @@ impl Args {
} else {
return Err(types::ParseError::throw_invalid("Picker choice must be an integer between 0 and 255"));
}
},
ExpectedFlags::Language => {
self.accept_language = arg.clone();
}
}
}
Expand Down Expand Up @@ -304,5 +315,5 @@ impl Args {

#[derive(Debug)]
enum ExpectedFlags {
VideoCodec, VideoQuality, AudioFormat, Output, FilenamePattern, Picker
VideoCodec, VideoQuality, AudioFormat, Output, FilenamePattern, Picker, Language
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ async fn execute_get_media(args: Args, bulk: u16, debug: bool) -> bool {
.header("User-Agent", &format!("tcobalt {}", VERSION.trim()))
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Accept-Language", &args.accept_language)
.body(json);

if debug { eprintln!("[DEBUG {download_url}] Sending POST request to cobalt server ...") };
Expand Down

0 comments on commit 4a596ef

Please sign in to comment.