support custom resolutions
All checks were successful
Trigger quay.io Webhook / run (push) Successful in 7s
All checks were successful
Trigger quay.io Webhook / run (push) Successful in 7s
This commit is contained in:
parent
d5bb7a4bdc
commit
dd5847da48
1 changed files with 24 additions and 1 deletions
|
@ -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),
|
||||||
_ => 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)]
|
#[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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue