player: warn against using HLS URLs with --playlist

That just makes no sense, but seems to be a somewhat common user error.

The detection is not perfect. It's conceivable that EXT-X-... headers
are used in normal m3u playlists. After all, HLS playlists are by
definition a compatible extension to m3u playlists, as stupid as it
sounds.
This commit is contained in:
wm4 2015-08-04 17:04:56 +02:00
parent e7897dfb9b
commit 0b1c3e8de2
2 changed files with 8 additions and 1 deletions

View File

@ -281,6 +281,10 @@ struct playlist *playlist_parse_file(const char *file, struct mpv_global *global
if (d && d->playlist) {
ret = talloc_zero(NULL, struct playlist);
playlist_transfer_entries(ret, d->playlist);
if (d->filetype && strcmp(d->filetype, "hls") == 0) {
mp_warn(log, "This might be a HLS stream. For correct operation, "
"pass it to the player\ndirectly. Don't use --playlist.\n");
}
}
free_demuxer_and_stream(d);

View File

@ -54,6 +54,7 @@ struct pl_parser {
bool add_base;
enum demux_check check_level;
struct stream *real_stream;
char *format;
};
static char *pl_get_line0(struct pl_parser *p)
@ -120,6 +121,8 @@ ok:
talloc_free(title);
title = bstrto0(NULL, btitle);
}
} else if (bstr_startswith0(line, "#EXT-X-")) {
p->format = "hls";
} else if (line.len > 0 && !bstr_startswith0(line, "#")) {
char *fn = bstrto0(NULL, line);
struct playlist_entry *e = playlist_entry_new(fn);
@ -338,7 +341,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
if (p->add_base)
playlist_add_base_path(p->pl, mp_dirname(demuxer->filename));
demuxer->playlist = talloc_steal(demuxer, p->pl);
demuxer->filetype = fmt->name;
demuxer->filetype = p->format ? p->format : fmt->name;
demuxer->fully_read = true;
talloc_free(p);
return ok ? 0 : -1;