Add fix for rule DashInTitle
This commit is contained in:
parent
c840b080f6
commit
0fa2931a64
3 changed files with 23 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
use regex::Captures;
|
use regex::Captures;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::utils::constructors::episode_name;
|
||||||
|
|
||||||
pub struct DashInTitle {}
|
pub struct DashInTitle {}
|
||||||
impl Rule for DashInTitle {
|
impl Rule for DashInTitle {
|
||||||
|
@ -14,7 +15,20 @@ impl Rule for DashInTitle {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix(_filename: &str, _captures: &Captures) -> Result<FixStatus> {
|
fn fix(_filename: &str, captures: &Captures) -> Result<FixStatus> {
|
||||||
return Ok(FixStatus::NotImplemented)
|
let ep_name = match captures.name("name") {
|
||||||
|
Some(ep) => Some(ep.as_str().to_string()),
|
||||||
|
None => None
|
||||||
|
};
|
||||||
|
|
||||||
|
let name = episode_name(
|
||||||
|
captures.name("title").unwrap().as_str().to_string(),
|
||||||
|
captures.name("season").unwrap().as_str().to_string(),
|
||||||
|
captures.name("episode").unwrap().as_str().to_string(),
|
||||||
|
ep_name,
|
||||||
|
captures.name("ext").unwrap().as_str().to_string()
|
||||||
|
);
|
||||||
|
|
||||||
|
return Ok(FixStatus::Fixed(name))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,9 +37,9 @@ pub enum ComplianceStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum FixStatus {
|
pub enum FixStatus {
|
||||||
// Fixed,
|
Fixed(String),
|
||||||
NotImplemented,
|
NotImplemented,
|
||||||
// NotFixable
|
NotFixable
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Rule {
|
pub trait Rule {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#[allow(dead_code)]
|
pub fn episode_name(title: String, season: String, episode: String, name: Option<String>, format: String) -> String {
|
||||||
pub fn episode_name(title: String, season: String, episode: String, name: String, format: String) -> String {
|
match name {
|
||||||
format!("${title} S${season}E${episode} - ${name}.${format}")
|
Some(n) => format!("{} S{}E{} - {}.{}", title, season, episode, n, format),
|
||||||
|
None => format!("{} S{}E{}.{}", title, season, episode, format),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue