diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2015-02-23 18:59:32 +0100 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2015-02-25 11:00:55 +0900 |
commit | edf0b93703fab7ef01272f4e164a6916ad228046 (patch) | |
tree | 972f5b59638b1b6b44219c4115fe2a154871aa78 /player | |
parent | 6bf46eae23c53bc5b909432d2b7d9ffba562635e (diff) | |
download | mpv-edf0b93703fab7ef01272f4e164a6916ad228046.tar.bz2 mpv-edf0b93703fab7ef01272f4e164a6916ad228046.tar.xz |
ytdl: Adapt to new subtitles structure
The requested formats can be sorted by preference and the result gives now an url or the subtitles file content
(cherry picked from commit 7281a72fabc610c70b4803ffb739c4155862c2d0)
Diffstat (limited to 'player')
-rw-r--r-- | player/lua/ytdl_hook.lua | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index b947fdec86..acdb23ae3f 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -3,7 +3,7 @@ local msg = require 'mp.msg' local ytdl = { path = "youtube-dl", - minver = "2014.11.26", + minver = "2015.02.23.1", vercheck = nil, } @@ -82,10 +82,7 @@ mp.add_hook("on_load", 10, function () local format = mp.get_property("options/ytdl-format") -- subformat workaround - local subformat = "srt" - if url:find("crunchyroll.com") then - subformat = "ass" - end + local subformat = "ass/srt/best" local command = { ytdl.path, "-J", "--flat-playlist", "--all-subs", @@ -209,8 +206,8 @@ mp.add_hook("on_load", 10, function () mp.set_property("file-local-options/media-title", json.title) -- add subtitles - if not (json.subtitles == nil) then - for lang, script in pairs(json.subtitles) do + if not (json.requested_subtitles == nil) then + for lang, sub_info in pairs(json.requested_subtitles) do msg.verbose("adding subtitle ["..lang.."]") local slang = lang @@ -218,8 +215,13 @@ mp.add_hook("on_load", 10, function () slang = lang:sub(1,2) end - mp.commandv("sub_add", "memory://"..script, - "auto", lang.." "..subformat, slang) + if not (sub_info.data == nil) then + sub = "memory://"..sub_info.data + else + sub = sub_info.url + end + mp.commandv("sub_add", sub, + "auto", lang.." "..sub_info.ext, slang) end end |