From 7eb34275732071acf779a0f241642411f91f78b7 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Fri, 26 Jan 2018 20:57:10 +0000 Subject: ytdl_hook: prefer hls/dash manifest if available This makes all the video/audio variants available for selection. Might break with non-hls/dash, or even with dash if FFmpeg wasn't compiled with the demuxer. --- player/lua/ytdl_hook.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 6c8e78657d..959b8179db 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -235,9 +235,13 @@ end local function add_single_video(json) local streamurl = "" local max_bitrate = 0 + local reqfmts = json["requested_formats"] - if has_native_dash_demuxer() and proto_is_dash(json) then - local mpd_url = json["requested_formats"][1]["manifest_url"] or + -- prefer manifest_url if present + if (has_native_dash_demuxer() and proto_is_dash(json)) or + (reqfmts and reqfmts[1]["manifest_url"]) or + json["manifest_url"] then + local mpd_url = reqfmts and reqfmts[1]["manifest_url"] or json["manifest_url"] if not mpd_url then msg.error("No manifest URL found in JSON data.") @@ -248,8 +252,8 @@ local function add_single_video(json) streamurl = mpd_url - if json.requested_formats then - for _, track in pairs(json.requested_formats) do + if reqfmts then + for _, track in pairs(reqfmts) do max_bitrate = track.tbr > max_bitrate and track.tbr or max_bitrate end @@ -258,8 +262,8 @@ local function add_single_video(json) end -- DASH/split tracks - elseif not (json["requested_formats"] == nil) then - for _, track in pairs(json.requested_formats) do + elseif reqfmts then + for _, track in pairs(reqfmts) do local edl_track = nil edl_track = edl_track_joined(track.fragments, track.protocol, json.is_live, -- cgit v1.2.3