mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-25 19:58:36 -06:00
Skip irrelevant files
This commit is contained in:
parent
e1af92739b
commit
a1c4fb816e
2 changed files with 13 additions and 1 deletions
|
@ -35,6 +35,14 @@ pub fn process_file(
|
||||||
|
|
||||||
// Parse the filename for metadata
|
// Parse the filename for metadata
|
||||||
let metadata = Metadata::from(file_base.as_str()).expect(" Could not parse filename!");
|
let metadata = Metadata::from(file_base.as_str()).expect(" Could not parse filename!");
|
||||||
|
|
||||||
|
// Process only if it's a valid file format
|
||||||
|
let mut extension = metadata.extension().unwrap_or("").to_string();
|
||||||
|
if !["mp4", "avi", "mkv", "flv", "m4a", "srt", "ssa"].contains(&extension.as_str()) {
|
||||||
|
println!(" Ignoring {}...", file_base);
|
||||||
|
return ("n/a".to_string(), false);
|
||||||
|
}
|
||||||
|
|
||||||
// Search using the TMDb API
|
// Search using the TMDb API
|
||||||
let mut search = tmdb.search();
|
let mut search = tmdb.search();
|
||||||
search.title(metadata.title());
|
search.title(metadata.title());
|
||||||
|
@ -86,7 +94,6 @@ pub fn process_file(
|
||||||
.prompt()
|
.prompt()
|
||||||
.expect(" Invalid choice!");
|
.expect(" Invalid choice!");
|
||||||
|
|
||||||
let mut extension = metadata.extension().unwrap_or("").to_string();
|
|
||||||
// Handle the case for subtitle files
|
// Handle the case for subtitle files
|
||||||
let mut is_subtitle = false;
|
let mut is_subtitle = false;
|
||||||
if ["srt", "ssa"].contains(&extension.as_str()) {
|
if ["srt", "ssa"].contains(&extension.as_str()) {
|
||||||
|
|
|
@ -66,6 +66,11 @@ fn main() {
|
||||||
pattern,
|
pattern,
|
||||||
settings["dry_run"],
|
settings["dry_run"],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if movie_name_temp == "n/a".to_string() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if is_subtitle == false {
|
if is_subtitle == false {
|
||||||
movie_count += 1;
|
movie_count += 1;
|
||||||
movie_name = movie_name_temp;
|
movie_name = movie_name_temp;
|
||||||
|
|
Loading…
Reference in a new issue