diff --git a/src/project.rs b/src/project.rs index 93d7a45..82eba5d 100644 --- a/src/project.rs +++ b/src/project.rs @@ -94,7 +94,17 @@ impl FromStr for Resolution { "1080p" | "fhd" | "fullhd" => Self(1920, 1080), "1440p" | "wqhd" => Self(2560, 1440), "2160p" | "4k" | "uhd" => Self(3840, 2160), - _ => anyhow::bail!("Unknown Resolution: {s:?}") + lower => { + let mut parts = lower.split('x'); + match ( + parts.next().map(|width| width.parse()), + parts.next().map(|height| height.parse()), + parts.next() + ) { + (Some(Ok(width)), Some(Ok(height)), None) => Self(width, height), + _ => anyhow::bail!("Unknown Resolution: {s:?}") + } + } }) } } @@ -204,3 +214,16 @@ pub struct ProjectProgress { #[serde(default)] pub transcoded: BTreeSet } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_custom_resolution() { + assert_eq!( + Resolution(1920, 1334), + "1920x1334".parse::().unwrap() + ); + } +}