summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChrisK2 <spam@kalania.de>2015-01-16 06:59:16 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:10 +0900
commite02146b0c0c45075d8bdbc60ce4b2e0a557aec33 (patch)
treef90268cc7c18674531de4ead07830d4590783e79
parent804468b1ac0fcbf40e3759ed1e6e9921e26ad5a7 (diff)
downloadmpv-e02146b0c0c45075d8bdbc60ce4b2e0a557aec33.tar.bz2
mpv-e02146b0c0c45075d8bdbc60ce4b2e0a557aec33.tar.xz
ytdl_hook: Check for empty playlists
Sometimes we get empty playlists back, print a warning message instead of crash
-rw-r--r--player/lua/ytdl_hook.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index b9480784eb..d59b3a4fd9 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -97,6 +97,12 @@ mp.add_hook("on_load", 10, function ()
elseif not (json["_type"] == nil) and (json["_type"] == "playlist") then
-- a playlist
+ if (#json.entries == 0) then
+ msg.warn("Got empty playlist, nothing to play.")
+ return
+ end
+
+
-- some funky guessing to detect multi-arc videos
if not (json.entries[1]["webpage_url"] == nil)
and (json.entries[1]["webpage_url"] == json["webpage_url"]) then
@@ -145,7 +151,7 @@ mp.add_hook("on_load", 10, function ()
if not (json["requested_formats"] == nil) then
msg.info("Using DASH, expect inaccurate duration.")
if not (json.duration == nil) then
- msg.info("actual duration: " .. mp.format_time(json.duration))
+ msg.info("Actual duration: " .. mp.format_time(json.duration))
end
-- video url