demux_playlist: expand tilde placeholders in playlist files

This allows playing something like an m3u containing ~/foo.mp4 or
~~/foo.mp4.

URLs like memory://#EXTM3U\n~/foo.mp4 also work.
This commit is contained in:
Guido Cella authored and Dudemanguy committed 2026-01-12 15:10:37 +00:00
1 parent 8bbcdec992
commit bbcd68f8ed
1 file changed
+5 -5
+5 -5
View File
@@ -218,19 +218,19 @@ static void pl_free_line(struct pl_parser *p, bstr line)
static void pl_add(struct pl_parser *p, bstr entry)
{
char *path;
void *ctx = talloc_new(NULL);
char *path = mp_get_user_path(ctx, p->global, bstrto0(ctx, entry));
bstr proto = mp_split_proto(bstr0(p->s->url), NULL);
// Don't add base path to self-expanding protocols
if (!mp_is_url(entry) && bstrcasecmp0(proto, "memory") &&
bstrcasecmp0(proto, "lavf") && bstrcasecmp0(proto, "hex") &&
bstrcasecmp0(proto, "data") && bstrcasecmp0(proto, "fd")) {
path = mp_path_join_bstr(NULL, mp_dirname(p->s->url), entry);
} else {
path = bstrto0(NULL, entry);
path = mp_path_join_bstr(ctx, mp_dirname(p->s->url), bstr0(path));
}
playlist_append_file(p->pl, path);
talloc_free(path);
talloc_free(ctx);
}
static bool pl_eof(struct pl_parser *p)