Skip to content

Commit f5bf7e8

Browse files
committed
feat: support subtitle font URLs
1 parent 9f5a210 commit f5bf7e8

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/types/resource/subtitles.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ pub struct Subtitles {
1616
pub url: Url,
1717
#[serde(default, skip_serializing_if = "Option::is_none")]
1818
pub label: Option<String>,
19+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
20+
pub fonts: Vec<Url>,
1921
}

src/unit_tests/serde/subtitles.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fn subtitles() {
1010
lang: "lang".to_owned(),
1111
url: Url::parse("https://url").unwrap(),
1212
label: None,
13+
fonts: vec![],
1314
},
1415
&[
1516
Token::Struct {
@@ -35,6 +36,7 @@ fn subtitles_with_label() {
3536
lang: "eng".to_owned(),
3637
url: Url::parse("https://url").unwrap(),
3738
label: Some("eng #1 [opensubtitles] 1080p.BluRay".to_owned()),
39+
fonts: vec![],
3840
},
3941
&[
4042
Token::Struct {
@@ -54,3 +56,37 @@ fn subtitles_with_label() {
5456
],
5557
);
5658
}
59+
60+
#[test]
61+
fn subtitles_with_fonts() {
62+
assert_tokens(
63+
&Subtitles {
64+
id: "id".into(),
65+
lang: "eng".to_owned(),
66+
url: Url::parse("https://url").unwrap(),
67+
label: None,
68+
fonts: vec![
69+
Url::parse("https://example.com/font.ttf").unwrap(),
70+
Url::parse("https://example.com/font.otf").unwrap(),
71+
],
72+
},
73+
&[
74+
Token::Struct {
75+
name: "Subtitles",
76+
len: 4,
77+
},
78+
Token::Str("id"),
79+
Token::Str("id"),
80+
Token::Str("lang"),
81+
Token::Str("eng"),
82+
Token::Str("url"),
83+
Token::Str("https://url/"),
84+
Token::Str("fonts"),
85+
Token::Seq { len: Some(2) },
86+
Token::Str("https://example.com/font.ttf"),
87+
Token::Str("https://example.com/font.otf"),
88+
Token::SeqEnd,
89+
Token::StructEnd,
90+
],
91+
);
92+
}

0 commit comments

Comments
 (0)