feat(api): extract an embedded track on demand (#261)
ci / web (push) Successful in 40s
ci / rust (push) Successful in 3m22s
e2e / e2e (push) Failing after 3m31s

Closes #260.
This commit was merged in pull request #261.
This commit is contained in:
2026-08-26 12:08:42 +01:00
parent dfa4656509
commit adb61dda3b
9 changed files with 666 additions and 28 deletions
+38 -1
View File
@@ -364,6 +364,23 @@ impl SubtitleCodec {
pub const fn is_text(self) -> bool {
matches!(self, Self::SubRip | Self::Ass | Self::MovText)
}
/// The inverse of [`Display`](fmt::Display): read back a codec that was
/// written out under its `ffprobe` name. `ffprobe`'s own aliases are
/// accepted alongside, so a column written by an older probe still
/// resolves. Anything unrecognised is [`Self::Other`], which extracts
/// nothing — the same answer as a bitmap track.
#[must_use]
pub fn from_probe_name(name: &str) -> Self {
match name {
"subrip" | "srt" => Self::SubRip,
"ass" | "ssa" => Self::Ass,
"mov_text" => Self::MovText,
"hdmv_pgs_subtitle" => Self::Pgs,
"dvd_subtitle" => Self::VobSub,
_ => Self::Other,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -490,7 +507,7 @@ pub struct MovieOwner {
#[cfg(test)]
mod tests {
use super::{DolbyVisionProfile, HdrFormat, Language, Rule, Verdict};
use super::{DolbyVisionProfile, HdrFormat, Language, Rule, SubtitleCodec, Verdict};
#[test]
fn portuguese_variants_are_distinct() {
@@ -512,6 +529,26 @@ mod tests {
);
}
#[test]
fn probe_names_round_trip_through_the_codec() {
for codec in [
SubtitleCodec::SubRip,
SubtitleCodec::Ass,
SubtitleCodec::MovText,
SubtitleCodec::Pgs,
SubtitleCodec::VobSub,
] {
assert_eq!(SubtitleCodec::from_probe_name(&codec.to_string()), codec);
}
assert_eq!(SubtitleCodec::from_probe_name("srt"), SubtitleCodec::SubRip);
assert_eq!(SubtitleCodec::from_probe_name("ssa"), SubtitleCodec::Ass);
assert_eq!(
SubtitleCodec::from_probe_name("dvb_subtitle"),
SubtitleCodec::Other
);
assert!(!SubtitleCodec::from_probe_name("other").is_text());
}
#[test]
fn non_eligible_verdicts_name_the_rule() {
let rule = Rule::DolbyVisionProfile(DolbyVisionProfile {