mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2024-12-22 14:36:28 +00:00
Merge pull request #18 from thaytan/17-fix-master-playlists
Handle blank lines when checking for master playlist tags.
This commit is contained in:
commit
cd9402051e
2 changed files with 13 additions and 2 deletions
10
sample-playlists/master-playlist-with-blankline.m3u8
Normal file
10
sample-playlists/master-playlist-with-blankline.m3u8
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue