mirror of https://github.com/mpv-player/mpv
ytdl: Try to handle multi-arc videos
this currently uses a sketchy but apparently working workaround, which will be removed once the neccessary changes in youtube-dl are implemented Fixes #1277
This commit is contained in:
parent
07ddfd4f8a
commit
13845cf6fe
|
@ -97,23 +97,46 @@ mp.add_hook("on_load", 10, function ()
|
||||||
elseif not (json["_type"] == nil) and (json["_type"] == "playlist") then
|
elseif not (json["_type"] == nil) and (json["_type"] == "playlist") then
|
||||||
-- a playlist
|
-- a playlist
|
||||||
|
|
||||||
local playlist = "#EXTM3U\n"
|
-- some funky guessing to detect multi-arc videos
|
||||||
for i, entry in pairs(json.entries) do
|
if not (json.entries[1]["webpage_url"] == nil)
|
||||||
local site = entry.url
|
and (json.entries[1]["webpage_url"] == json["webpage_url"]) then
|
||||||
|
msg.verbose("multi-arc video detected, building EDL")
|
||||||
|
|
||||||
-- some extractors will still return the full info for
|
|
||||||
-- all clips in the playlist and the URL will point
|
local playlist = "edl://"
|
||||||
-- directly to the file in that case, which we don't
|
for i, entry in pairs(json.entries) do
|
||||||
-- want so get the webpage URL instead, which is what
|
|
||||||
-- we want
|
playlist = playlist .. entry.url .. ";"
|
||||||
if not (entry["webpage_url"] == nil) then
|
|
||||||
site = entry["webpage_url"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
playlist = playlist .. "ytdl://" .. site .. "\n"
|
msg.debug("EDL: " .. playlist)
|
||||||
end
|
|
||||||
|
|
||||||
mp.set_property("stream-open-filename", "memory://" .. playlist)
|
|
||||||
|
mp.set_property("stream-open-filename", playlist)
|
||||||
|
if not (json.title == nil) then
|
||||||
|
mp.set_property("file-local-options/media-title", json.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
local playlist = "#EXTM3U\n"
|
||||||
|
for i, entry in pairs(json.entries) do
|
||||||
|
local site = entry.url
|
||||||
|
|
||||||
|
-- some extractors will still return the full info for
|
||||||
|
-- all clips in the playlist and the URL will point
|
||||||
|
-- directly to the file in that case, which we don't
|
||||||
|
-- want so get the webpage URL instead, which is what
|
||||||
|
-- we want
|
||||||
|
if not (entry["webpage_url"] == nil) then
|
||||||
|
site = entry["webpage_url"]
|
||||||
|
end
|
||||||
|
|
||||||
|
playlist = playlist .. "ytdl://" .. site .. "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
mp.set_property("stream-open-filename", "memory://" .. playlist)
|
||||||
|
end
|
||||||
|
|
||||||
else -- probably a video
|
else -- probably a video
|
||||||
local streamurl = ""
|
local streamurl = ""
|
||||||
|
|
Loading…
Reference in New Issue