mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-21 14:50:59 +00:00
fix issue #64
This commit is contained in:
parent
6c694d186d
commit
3a742a95b6
4 changed files with 43 additions and 10 deletions
|
@ -30,7 +30,8 @@ impl<'a> Iterator for AttributePairs<'a> {
|
|||
// NOTE: it is okay to add 1 to the index, because an `=` is exactly 1 byte.
|
||||
self.index = end + 1;
|
||||
|
||||
&self.string[start..end]
|
||||
// NOTE: See https://github.com/sile/hls_m3u8/issues/64
|
||||
self.string[start..end].trim()
|
||||
};
|
||||
|
||||
let value = {
|
||||
|
@ -66,7 +67,8 @@ impl<'a> Iterator for AttributePairs<'a> {
|
|||
self.index += end;
|
||||
self.index -= start;
|
||||
|
||||
&self.string[start..end]
|
||||
// NOTE: See https://github.com/sile/hls_m3u8/issues/64
|
||||
self.string[start..end].trim()
|
||||
};
|
||||
|
||||
Some((key, value))
|
||||
|
@ -190,7 +192,7 @@ mod test {
|
|||
assert_eq!((1, Some(1)), pairs.size_hint());
|
||||
assert_eq!(
|
||||
pairs.next(),
|
||||
Some(("ध्वनि स्थिति और्४५० नीचे ", "देखने लाभो द्वारा करके(विशेष"))
|
||||
Some(("ध्वनि स्थिति और्४५० नीचे", "देखने लाभो द्वारा करके(विशेष"))
|
||||
);
|
||||
|
||||
assert_eq!((0, Some(0)), pairs.size_hint());
|
||||
|
|
|
@ -348,13 +348,7 @@ impl<'a> TryFrom<&'a str> for VariantStream<'a> {
|
|||
fn try_from(input: &'a str) -> Result<Self, Self::Error> {
|
||||
if let Ok(input) = tag(input, Self::PREFIX_EXTXIFRAME) {
|
||||
let uri = AttributePairs::new(input)
|
||||
.find_map(|(key, value)| {
|
||||
if key == "URI" {
|
||||
Some(unquote(value))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.find_map(|(key, value)| (key == "URI").then(|| unquote(value)))
|
||||
.ok_or_else(|| Error::missing_value("URI"))?;
|
||||
|
||||
Ok(Self::ExtXIFrame {
|
||||
|
|
3
tests/issues/assets/issue_00064.m3u8
Normal file
3
tests/issues/assets/issue_00064.m3u8
Normal file
|
@ -0,0 +1,3 @@
|
|||
#EXTM3U
|
||||
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=10000000
|
||||
https://995107575.cloudvdn.com/a.m3u8?cdn=cn-gotcha03&domain=d1--cn-gotcha103.bilivideo.com&expires=1614619920&len=0&oi=1891753406&order=1&player=70YAALwcl0b9RGgW&pt=h5&ptype=0&qn=10000&secondToken=secondToken%3ACZ4ggpPHomuwcnT8XWDjJUp9eh8&sign=325afc8bc3b01ccbadeac084004ece64&sigparams=cdn%2Cexpires%2Clen%2Coi%2Cpt%2Cqn%2Ctrid&sl=1&src=4&streamid=live-qn%3Alive-qn%2Flive_402401719_42665292&trid=20d9f245179b4ef3a7e3635afaaa87ea&v3=1
|
34
tests/issues/issue_00064.rs
Normal file
34
tests/issues/issue_00064.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// The relevant issue:
|
||||
// https://github.com/sile/hls_m3u8/issues/55
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use hls_m3u8::tags::VariantStream;
|
||||
use hls_m3u8::types::StreamData;
|
||||
use hls_m3u8::MasterPlaylist;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn parse() {
|
||||
let file = include_str!("assets/issue_00064.m3u8");
|
||||
|
||||
assert_eq!(
|
||||
MasterPlaylist::try_from(file).unwrap(),
|
||||
MasterPlaylist::builder()
|
||||
.variant_streams(vec![
|
||||
VariantStream::ExtXStreamInf {
|
||||
uri: "https://995107575.cloudvdn.com/a.m3u8?cdn=cn-gotcha03&domain=d1--cn-gotcha103.bilivideo.com&expires=1614619920&len=0&oi=1891753406&order=1&player=70YAALwcl0b9RGgW&pt=h5&ptype=0&qn=10000&secondToken=secondToken%3ACZ4ggpPHomuwcnT8XWDjJUp9eh8&sign=325afc8bc3b01ccbadeac084004ece64&sigparams=cdn%2Cexpires%2Clen%2Coi%2Cpt%2Cqn%2Ctrid&sl=1&src=4&streamid=live-qn%3Alive-qn%2Flive_402401719_42665292&trid=20d9f245179b4ef3a7e3635afaaa87ea&v3=1".into(),
|
||||
frame_rate: None,
|
||||
audio: None,
|
||||
subtitles: None,
|
||||
closed_captions: None,
|
||||
stream_data: StreamData::builder()
|
||||
.bandwidth(10000000)
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
])
|
||||
.build()
|
||||
.unwrap()
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue