From 8e82a64f5665dfeec2b0ae34b52f1870720f049e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Jul 2015 21:22:35 +0200 Subject: player: parse and expose m3u playlist titles Requested. Closes #2100. --- demux/demux_playlist.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'demux/demux_playlist.c') diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 4f48a99b1a..0afda57c6a 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -112,11 +112,25 @@ static int parse_m3u(struct pl_parser *p) ok: if (p->probing) return 0; + char *title = NULL; while (line.len || !pl_eof(p)) { - if (line.len > 0 && !bstr_startswith0(line, "#")) - pl_add(p, line); + if (bstr_eatstart0(&line, "#EXTINF:")) { + bstr duration, btitle; + if (bstr_split_tok(line, ",", &duration, &btitle) && btitle.len) { + talloc_free(title); + title = bstrto0(NULL, btitle); + } + } else if (line.len > 0 && !bstr_startswith0(line, "#")) { + char *fn = bstrto0(NULL, line); + struct playlist_entry *e = playlist_entry_new(fn); + talloc_free(fn); + e->title = talloc_steal(e, title); + title = NULL; + playlist_add(p->pl, e); + } line = bstr_strip(pl_get_line(p)); } + talloc_free(title); return 0; } -- cgit v1.2.3