From edf0b93703fab7ef01272f4e164a6916ad228046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Mon, 23 Feb 2015 18:59:32 +0100 Subject: 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) --- player/lua/ytdl_hook.lua | 20 +++++++++++--------- 1 file 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 -- cgit v1.2.3