Compare commits
No commits in common. "develop" and "main" have entirely different histories.
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -841,7 +841,7 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "plex-media-ingest"
|
name = "plex-media-ingest"
|
||||||
version = "1.0.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"home",
|
"home",
|
||||||
|
|
34
src/show.rs
34
src/show.rs
|
@ -8,7 +8,7 @@ use serde::Deserialize;
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use inline_colorization::*;
|
use inline_colorization::*;
|
||||||
use regex::{Captures, RegexBuilder};
|
use regex::RegexBuilder;
|
||||||
|
|
||||||
use crate::{config::Config, media::{Move, self, get_file_header}, directory::search_path};
|
use crate::{config::Config, media::{Move, self, get_file_header}, directory::search_path};
|
||||||
|
|
||||||
|
@ -157,36 +157,12 @@ fn check_show_file(file: PathBuf, primary_media: &mut Option<TMDBEntry>, cfg: &C
|
||||||
trace!("Checking {:#?}", file);
|
trace!("Checking {:#?}", file);
|
||||||
match get_file_header(file.clone()) {
|
match get_file_header(file.clone()) {
|
||||||
Ok(header) => {
|
Ok(header) => {
|
||||||
let season :i32;
|
|
||||||
let episode :i32;
|
|
||||||
let caps :Captures;
|
|
||||||
// Try to parse Season/Episode from filename
|
// Try to parse Season/Episode from filename
|
||||||
let re = RegexBuilder::new(r"(?:S(?<season0>[0-9]+).?E(?<episode0>[0-9]+)|(?<season1>[0-9]+)x(?<episode1>[0-9]+))")
|
let re = RegexBuilder::new(r"(?:S(?<season0>[0-9]+)\.?E(?<episode0>[0-9]+)|(?<season1>[0-9]+)x(?<episode1>[0-9]+))")
|
||||||
.case_insensitive(true).build().unwrap();
|
.case_insensitive(true).build().unwrap();
|
||||||
if re.is_match(file.to_str().unwrap_or_default()) {
|
let Some(caps) = re.captures(file.to_str().unwrap_or_default()) else { warn!("Regex doesn't match {:#?}, skipping", file); return; };
|
||||||
caps = re.captures(file.to_str().unwrap_or_default()).unwrap()
|
let season: i32 = caps.name("season0").map_or_else(||caps.name("season1").map_or("", |m| m.as_str()), |m| m.as_str()).parse().unwrap();
|
||||||
} else {
|
let episode: i32 = caps.name("episode0").map_or_else(||caps.name("episode1").map_or("", |m| m.as_str()), |m| m.as_str()).parse().unwrap();
|
||||||
// Try alternate regex that includes folder name
|
|
||||||
let re = RegexBuilder::new(r"(?:Season (?<season0>[0-9]+)[\/\\][\D]+?(?<episode0>[0-9]+))")
|
|
||||||
.case_insensitive(true).build().unwrap();
|
|
||||||
if re.is_match(file.to_str().unwrap_or_default()) {
|
|
||||||
caps = re.captures(file.to_str().unwrap_or_default()).unwrap()
|
|
||||||
} else {
|
|
||||||
warn!("Regex doesn't match {:#?}, skipping", file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
season = caps.name("season0").map_or_else(
|
|
||||||
||caps.name("season1").map_or_else(
|
|
||||||
||caps.name("season2").map_or(
|
|
||||||
"", |m| m.as_str()), |m| m.as_str()), |m| m.as_str()).parse().unwrap();
|
|
||||||
|
|
||||||
episode = caps.name("episode0").map_or_else(
|
|
||||||
||caps.name("episode1").map_or_else(
|
|
||||||
||caps.name("episode2").map_or(
|
|
||||||
"", |m| m.as_str()), |m| m.as_str()), |m| m.as_str()).parse().unwrap();
|
|
||||||
|
|
||||||
trace!("Found Season {0:02}, Episode {1:02}", season, episode);
|
trace!("Found Season {0:02}, Episode {1:02}", season, episode);
|
||||||
|
|
||||||
// Handle video files
|
// Handle video files
|
||||||
|
|
Loading…
Reference in a new issue