support custom resolutions
All checks were successful
Trigger quay.io Webhook / run (push) Successful in 7s

This commit is contained in:
Dominic 2025-01-17 17:55:58 +01:00
parent d5bb7a4bdc
commit dd5847da48
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D

View file

@ -94,7 +94,17 @@ impl FromStr for Resolution {
"1080p" | "fhd" | "fullhd" => Self(1920, 1080), "1080p" | "fhd" | "fullhd" => Self(1920, 1080),
"1440p" | "wqhd" => Self(2560, 1440), "1440p" | "wqhd" => Self(2560, 1440),
"2160p" | "4k" | "uhd" => Self(3840, 2160), "2160p" | "4k" | "uhd" => Self(3840, 2160),
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:?}") _ => anyhow::bail!("Unknown Resolution: {s:?}")
}
}
}) })
} }
} }
@ -204,3 +214,16 @@ pub struct ProjectProgress {
#[serde(default)] #[serde(default)]
pub transcoded: BTreeSet<Resolution> pub transcoded: BTreeSet<Resolution>
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_custom_resolution() {
assert_eq!(
Resolution(1920, 1334),
"1920x1334".parse::<Resolution>().unwrap()
);
}
}