From ce78f1222fae74fdc5bd995a426124f2adcc241a Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Thu, 4 May 2017 17:10:07 +0100 Subject: [PATCH] ytdl_hook: rework edl joining to use lua tables Seems much more resource efficient than concatenating a string. --- player/lua/ytdl_hook.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 9f0e4941c2..db33437ba1 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -96,11 +96,13 @@ local function edl_track_joined(fragments, protocol, is_live) local edl = "edl://" local offset = 1 + local parts = {} if (protocol == "http_dash_segments") and not fragments[1].duration and not is_live then -- assume MP4 DASH initialization segment - edl = edl .. "!mp4_dash,init=" .. edl_escape(fragments[1].url) .. ";" + table.insert(parts, + "!mp4_dash,init=" .. edl_escape(fragments[1].url)) offset = 2 -- Check remaining fragments for duration; @@ -116,13 +118,13 @@ local function edl_track_joined(fragments, protocol, is_live) for i = offset, #fragments do local fragment = fragments[i] - edl = edl .. edl_escape(fragment.url) + table.insert(parts, edl_escape(fragment.url)) if fragment.duration then - edl = edl..",length="..fragment.duration + parts[#parts] = + parts[#parts] .. ",length="..fragment.duration end - edl = edl .. ";" end - return edl + return edl .. table.concat(parts, ";") .. ";" end local function add_single_video(json)