diff options
author | wm4 <wm4@nowhere> | 2015-07-10 21:22:35 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-10 21:22:35 +0200 |
commit | 8e82a64f5665dfeec2b0ae34b52f1870720f049e (patch) | |
tree | 2d7cc09097e15f260b6a594f72276299f1b25d9f /demux | |
parent | c2b61876c4e880f4f95413debb74b5435241f2d1 (diff) | |
download | mpv-8e82a64f5665dfeec2b0ae34b52f1870720f049e.tar.bz2 mpv-8e82a64f5665dfeec2b0ae34b52f1870720f049e.tar.xz |
player: parse and expose m3u playlist titles
Requested. Closes #2100.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_playlist.c | 18 |
1 files changed, 16 insertions, 2 deletions
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; } |