Skip to content

Commit dc5c6ad

Browse files
Guido Cellayatinlala
authored andcommitted
player/configfiles: write playlist titles in watch later files
If ytdl_hook extracted a playlist title, write it in the watch later redirect entry. This will be shown in the watch later menu.
1 parent ffebf7e commit dc5c6ad

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

player/configfiles.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,13 @@ static void write_filename(struct MPContext *mpctx, FILE *file, char *filename)
266266
}
267267
}
268268

269-
static void write_title(struct MPContext *mpctx, FILE *file)
269+
static void write_title(struct MPContext *mpctx, FILE *file, const char *title)
270270
{
271-
if (mpctx->opts->write_filename_in_watch_later_config) {
272-
const char *title = mp_find_non_filename_media_title(mpctx);
273-
if (title) {
274-
char write_title[1024] = {0};
275-
for (int n = 0; title[n] && n < sizeof(write_title) - 1; n++)
276-
write_title[n] = (unsigned char)title[n] < 32 ? '_' : title[n];
277-
fprintf(file, "# title: %s\n", write_title);
278-
}
271+
if (mpctx->opts->write_filename_in_watch_later_config && title) {
272+
char write_title[1024] = {0};
273+
for (int n = 0; title[n] && n < sizeof(write_title) - 1; n++)
274+
write_title[n] = (unsigned char)title[n] < 32 ? '_' : title[n];
275+
fprintf(file, "# title: %s\n", write_title);
279276
}
280277
}
281278

@@ -287,6 +284,8 @@ static void write_redirect(struct MPContext *mpctx, char *path)
287284
if (file) {
288285
fprintf(file, "# redirect entry\n");
289286
write_filename(mpctx, file, path);
287+
write_title(mpctx, file,
288+
mp_tags_get_str(mpctx->demuxer->metadata, "ytdl_playlist_title"));
290289
fclose(file);
291290
}
292291

@@ -352,7 +351,7 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
352351

353352
write_filename(mpctx, file, path);
354353

355-
write_title(mpctx, file);
354+
write_title(mpctx, file, mp_find_non_filename_media_title(mpctx));
356355

357356
bool write_start = true;
358357
double pos = get_playback_time(mpctx);

0 commit comments

Comments
 (0)