Skip to content

Commit 0467065

Browse files
committed
player: write title to watch_later file
write_title() writes the media title to the media's watch_later file as a comment if 'write-filename-in-watch-later-config' is set. Prior to this change, setting the option would only write a commented filename at the top of the file. Now the media title is commented below the filename, with the prefix "title: " Before: # https://example.com/watch?v=foobar start=35 gamma=1 After: # https://example.com/watch?v=foobar # title: Foo Bar (HD Video) start=35 gamma=1
1 parent 440f35a commit 0467065

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

player/configfiles.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,19 @@ static void write_filename(struct MPContext *mpctx, FILE *file, char *filename)
265265
}
266266
}
267267

268+
static void write_title(struct MPContext *mpctx, FILE *file)
269+
{
270+
if (mpctx->opts->write_filename_in_watch_later_config) {
271+
const char *title = mp_find_non_filename_media_title(mpctx);
272+
if (title) {
273+
char write_title[1024] = {0};
274+
for (int n = 0; title[n] && n < sizeof(write_title) - 1; n++)
275+
write_title[n] = (unsigned char)title[n] < 32 ? '_' : title[n];
276+
fprintf(file, "# title: %s\n", write_title);
277+
}
278+
}
279+
}
280+
268281
static void write_redirect(struct MPContext *mpctx, char *path)
269282
{
270283
char *conffile = mp_get_playback_resume_config_filename(mpctx, path);
@@ -337,6 +350,8 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
337350

338351
write_filename(mpctx, file, path);
339352

353+
write_title(mpctx, file);
354+
340355
bool write_start = true;
341356
double pos = get_playback_time(mpctx);
342357

0 commit comments

Comments
 (0)