diff --git a/sample-playlists/master-playlist-with-blankline.m3u8 b/sample-playlists/master-playlist-with-blankline.m3u8 new file mode 100644 index 0000000..c6d738d --- /dev/null +++ b/sample-playlists/master-playlist-with-blankline.m3u8 @@ -0,0 +1,10 @@ +#EXTM3U + +#EXT-X-STREAM-INF:BANDWIDTH=1280000,AVERAGE-BANDWIDTH=1000000 +http://example.com/low.m3u8 +#EXT-X-STREAM-INF:BANDWIDTH=2560000,AVERAGE-BANDWIDTH=2000000 +http://example.com/mid.m3u8 +#EXT-X-STREAM-INF:BANDWIDTH=7680000,AVERAGE-BANDWIDTH=6000000 +http://example.com/hi.m3u8 +#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5" +http://example.com/audio-only.m3u8 diff --git a/src/lib.rs b/src/lib.rs index dc7132e..3b8a1aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,7 +85,7 @@ pub mod playlist; use nom::character::complete::{digit1, multispace0, space0 }; use nom::{IResult}; -use nom::{ delimited,none_of,peek,is_not,complete,terminated,tag, +use nom::{ delimited,none_of,peek,is_a,is_not,complete,terminated,tag, alt,do_parse,opt,named,map,map_res,eof,many0,take,take_until,char}; use nom::combinator::map; use nom::character::complete::{line_ending}; @@ -222,7 +222,8 @@ pub fn contains_master_tag(input: &[u8]) -> Option<(bool, String)> { named!(pub is_master_playlist_tag_line(&[u8]) -> Option<(bool, String)>, do_parse!( - tag: opt!(alt!( + opt!(is_a!("\r\n")) + >> tag: opt!(alt!( map!(tag!("#EXT-X-STREAM-INF"), |t| (true, t)) | map!(tag!("#EXT-X-I-FRAME-STREAM-INF"), |t| (true, t)) | map!(terminated!(tag!("#EXT-X-MEDIA"), is_not!("-")), |t| (true, t)) // terminated!() to prevent matching with #EXT-X-MEDIA-SEQUENCE for which we have a separate pattern below