demux: add --autocreate-playlist

This commit is contained in:
Kacper Michajłow
2024-07-15 23:22:39 +02:00
parent 4b97c23dac
commit bb9b862f0c
4 changed files with 42 additions and 9 deletions

View File

@@ -1041,6 +1041,17 @@ void prepare_playlist(struct MPContext *mpctx, struct playlist *pl)
if (opts->playlist_pos >= 0)
pl->current = playlist_entry_from_index(pl, opts->playlist_pos);
for (int i = 0; i < pl->num_entries; ++i) {
if (!pl->entries[i]->playlist_path)
continue;
// If playlist_path exists as an element in the playlist itself, it means
// playlist was autogenerated.
if (!strcmp(pl->entries[i]->filename, pl->entries[i]->playlist_path)) {
pl->current = pl->entries[i];
break;
}
}
if (opts->shuffle)
playlist_shuffle(pl);
@@ -1144,6 +1155,7 @@ static MP_THREAD_VOID open_demux_thread(void *ctx)
.stream_flags = mpctx->open_url_flags,
.stream_record = true,
.is_top_level = true,
.has_playlist = mpctx->playlist->num_entries > 1,
};
struct demuxer *demux =
demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);