From 8ea7aa54719f790d64f3d96c63a7c8eaf756ca27 Mon Sep 17 00:00:00 2001 From: Christoph Heinrich Date: Sun, 26 Feb 2023 19:49:23 +0100 Subject: [PATCH] ytdl_hook: don't overwrite force-media-title ytdl_hook always set force-media-title, making users unable to force a media-title via options. To prevent that, check if force-media-title is already set to avoid overwriting it. A better solution would be to use tags like is already done for some metadata, however that doesn't work when `all_formats=yes` is used. See cbb8f534b064f144820435148e516978de08cb30 A comment was added to hint at why it isn't done via tags. ref. https://github.com/mpv-player/mpv/pull/10453#issuecomment-1445277496 --- player/lua/ytdl_hook.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 9d1584016c..3cb5f654dd 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -47,6 +47,7 @@ local tag_list = { -- (default --display-tags does not include this name) ["description"] = "ytdl_description", -- "title" is handled by force-media-title + -- tags don't work with all_formats=yes } local safe_protos = Set { @@ -629,7 +630,9 @@ local function add_single_video(json) mp.set_property("stream-open-filename", streamurl:gsub("^data:", "data://", 1)) - mp.set_property("file-local-options/force-media-title", json.title) + if mp.get_property("force-media-title", "") == "" then + mp.set_property("file-local-options/force-media-title", json.title) + end -- set hls-bitrate for dash track selection if max_bitrate > 0 and @@ -925,7 +928,7 @@ function run_ytdl_hook(url) set_http_headers(json.entries[1].http_headers) mp.set_property("stream-open-filename", playlist) - if not (json.title == nil) then + if json.title and mp.get_property("force-media-title", "") == "" then mp.set_property("file-local-options/force-media-title", json.title) end