From e529ab2100f497f050c5458d1374071a788a73a7 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 8 Dec 2022 00:21:36 -0600 Subject: [PATCH] Add subtitles support --- .gitignore | 1 + src/main.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index da5a7bb..3348a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target *.mp4 +*.srt *.key \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 92898e2..5db588a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,9 +91,20 @@ fn main() { .preview(display) .preview_label(filename.to_string()); let choice = menu.show()[0]; + + let mut extension = metadata.extension().unwrap_or("").to_string(); + if ["srt", "ssa"].contains(&extension.as_str()) { + let languages = Vec::from(["en", "hi", "bn", "de", "fr", "sp", "ja", "n/a"]); + let mut lang_menu = youchoose::Menu::new(languages.iter()); + let lang_choice = lang_menu.show()[0]; + if languages[lang_choice] != "none" { + extension = format!("{}.{}", languages[lang_choice], extension); + } + } + let mut new_name_vec = vec![ movie_list[choice].rename_format(pattern.to_string()), - metadata.extension().unwrap_or("").to_string(), + extension, ]; new_name_vec.retain(|x| !x.is_empty()); let new_name = new_name_vec.join(".");