demux_playlist: support .url files

Requested. Not tested due to lack of real samples. Fixes #5107.
This commit is contained in:
wm4 2017-11-12 15:51:48 +01:00
parent e2d0e0c6cb
commit 987291d042
1 changed files with 15 additions and 3 deletions

View File

@ -177,12 +177,13 @@ static int parse_ref_init(struct pl_parser *p)
return 0;
}
static int parse_pls(struct pl_parser *p)
static int parse_ini_thing(struct pl_parser *p, const char *header,
const char *entry)
{
bstr line = {0};
while (!line.len && !pl_eof(p))
line = bstr_strip(pl_get_line(p));
if (bstrcasecmp0(line, "[playlist]") != 0)
if (bstrcasecmp0(line, header) != 0)
return -1;
if (p->probing)
return 0;
@ -190,7 +191,7 @@ static int parse_pls(struct pl_parser *p)
line = bstr_strip(pl_get_line(p));
bstr key, value;
if (bstr_split_tok(line, "=", &key, &value) &&
bstr_case_startswith(key, bstr0("File")))
bstr_case_startswith(key, bstr0(entry)))
{
value = bstr_strip(value);
if (bstr_startswith0(value, "\"") && bstr_endswith0(value, "\""))
@ -201,6 +202,16 @@ static int parse_pls(struct pl_parser *p)
return 0;
}
static int parse_pls(struct pl_parser *p)
{
return parse_ini_thing(p, "[playlist]", "File");
}
static int parse_url(struct pl_parser *p)
{
return parse_ini_thing(p, "[InternetShortcut]", "URL");
}
static int parse_txt(struct pl_parser *p)
{
if (!p->force)
@ -319,6 +330,7 @@ static const struct pl_format formats[] = {
{"ini", parse_ref_init},
{"pls", parse_pls,
MIME_TYPES("audio/x-scpls")},
{"url", parse_url},
{"txt", parse_txt},
};