summaryrefslogtreecommitdiffstats
path: root/player/lua/ytdl_hook.lua
diff options
context:
space:
mode:
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r--player/lua/ytdl_hook.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index 586d4ea874..2c728455b8 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -38,6 +38,16 @@ function iif(cond, if_true, if_false)
return if_false
end
+-- youtube-dl JSON name to mpv tag name
+local tag_list = {
+ ["uploader"] = "uploader",
+ ["channel_url"] = "channel_url",
+ -- these titles tend to be a bit too long, so hide them on the terminal
+ -- (default --display-tags does not include this name)
+ ["description"] = "ytdl_description",
+ -- "title" is handled by force-media-title
+}
+
local safe_protos = Set {
"http", "https", "ftp", "ftps",
"rtmp", "rtmps", "rtmpe", "rtmpt", "rtmpts", "rtmpte",
@@ -341,6 +351,20 @@ local function as_integer(v, def)
return def
end
+local function tags_to_edl(json)
+ local tags = {}
+ for json_name, mp_name in pairs(tag_list) do
+ local v = json[json_name]
+ if v then
+ tags[#tags + 1] = mp_name .. "=" .. edl_escape(tostring(v))
+ end
+ end
+ if #tags == 0 then
+ return nil
+ end
+ return "!global_tags," .. table.concat(tags, ",")
+end
+
-- Convert a format list from youtube-dl to an EDL URL, or plain URL.
-- json: full json blob by youtube-dl
-- formats: format list by youtube-dl
@@ -475,6 +499,11 @@ local function formats_to_edl(json, formats, use_all_formats)
if #streams == 1 and single_url then
res.url = single_url
elseif #streams > 0 then
+ local tags = tags_to_edl(json)
+ if tags then
+ -- not a stream; just for the sake of concatenating the EDL string
+ streams[#streams + 1] = tags
+ end
res.url = "edl://" .. table.concat(streams, ";")
else
return nil