summaryrefslogtreecommitdiffstats
path: root/player/lua/ytdl_hook.lua
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2017-05-04 17:10:07 +0100
committerRicardo Constantino <wiiaboo@gmail.com>2017-05-04 17:10:07 +0100
commitce78f1222fae74fdc5bd995a426124f2adcc241a (patch)
tree9229ab1476dc49e9e02b96055ad17584bb8cd0bf /player/lua/ytdl_hook.lua
parent2eab0c779ade015319a8e1848f3f006f962f4e01 (diff)
downloadmpv-ce78f1222fae74fdc5bd995a426124f2adcc241a.tar.bz2
mpv-ce78f1222fae74fdc5bd995a426124f2adcc241a.tar.xz
ytdl_hook: rework edl joining to use lua tables
Seems much more resource efficient than concatenating a string.
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r--player/lua/ytdl_hook.lua12
1 files 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)