Don't bother parsing as a playlist or detecting if it's a master/media playlist if it doesn't start with #EXTM3U

This commit is contained in:
Sebastian Dröge 2021-11-19 11:29:46 +02:00
parent 53e9439660
commit 2fae1d8f20

View file

@ -42,6 +42,8 @@ use std::string;
/// }
/// ```
pub fn parse_playlist(input: &[u8]) -> IResult<&[u8], Playlist> {
m3u_tag(input)?;
match is_master_playlist(input) {
true => map(parse_master_playlist, Playlist::MasterPlaylist)(input),
false => map(parse_media_playlist, Playlist::MediaPlaylist)(input),
@ -135,6 +137,7 @@ pub fn is_master_playlist(input: &[u8]) -> bool {
/// - Some(true, tagstring): Line contains a master playlist tag
/// - Some(false, tagstring): Line contains a media playlist tag
fn contains_master_tag(input: &[u8]) -> Option<(bool, String)> {
let (input, _) = m3u_tag(input).ok()?;
let mut is_master_opt = None;
let mut current_input: &[u8] = input;