diff options
author | Ricardo Constantino <wiiaboo@gmail.com> | 2017-01-28 22:04:12 +0000 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-02-04 22:19:21 +0100 |
commit | a46fc5e5ebcb41fc6713bb083bd351d1d40556cb (patch) | |
tree | 791ef47362c19bf2586e14f17cc66b1cd8f1fd58 /player/lua | |
parent | 50991fac81eb56bc0985af2c9d31cd503302dcfe (diff) |
ytdl: support segmented dash
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index da548d47a1..7349e579e3 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -144,7 +144,7 @@ mp.add_hook("on_load", 10, function () format = "bestvideo+bestaudio" end table.insert(command, "--format") - table.insert(command, string.format('(%s)[protocol!=http_dash_segments]/best', format)) + table.insert(command, string.format('%s', format)) for param, arg in pairs(raw_options) do table.insert(command, "--" .. param) @@ -275,26 +275,30 @@ mp.add_hook("on_load", 10, function () else -- probably a video local streamurl = "" - -- DASH/split tracks (ex: bestvideo+bestaudio) - if (json["requested_formats"] ~= nil) then - - for i = 1, #json["requested_formats"] do - local track = json["requested_formats"][i] - + -- DASH/split tracks + if not (json["requested_formats"] == nil) then + for _, track in pairs(json.requested_formats) do + local edl_track = nil + if (track.protocol == "http_dash_segments") and + (track.fragments ~= nil) then + edl_track = edl_track_joined(track.fragments) + end if track.acodec and track.acodec ~= "none" then - -- audio url mp.commandv("audio-add", - track.url, "auto", + edl_track or track.url, "auto", track.format_note or "") elseif track.vcodec and track.vcodec ~= "none" then - -- video url - streamurl = track.url + streamurl = edl_track or track.url end end elseif not (json.url == nil) then + local edl_track = nil + if json.protocol == "http_dash_segments" then + edl_track = edl_track_joined(json.fragments) + end -- normal video - streamurl = json.url + streamurl = edl_track or json.url set_http_headers(json.http_headers) else msg.error("No URL found in JSON data.") |