mirror of
https://github.com/mpv-player/mpv
synced 2024-12-20 05:42:19 +00:00
ytdl_hook: Check for empty playlists
Sometimes we get empty playlists back, print a warning message instead of crash
This commit is contained in:
parent
70f43db95b
commit
1558938f87
@ -97,6 +97,12 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
elseif not (json["_type"] == nil) and (json["_type"] == "playlist") then
|
elseif not (json["_type"] == nil) and (json["_type"] == "playlist") then
|
||||||
-- a playlist
|
-- 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
|
-- some funky guessing to detect multi-arc videos
|
||||||
if not (json.entries[1]["webpage_url"] == nil)
|
if not (json.entries[1]["webpage_url"] == nil)
|
||||||
and (json.entries[1]["webpage_url"] == json["webpage_url"]) then
|
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
|
if not (json["requested_formats"] == nil) then
|
||||||
msg.info("Using DASH, expect inaccurate duration.")
|
msg.info("Using DASH, expect inaccurate duration.")
|
||||||
if not (json.duration == nil) then
|
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
|
end
|
||||||
|
|
||||||
-- video url
|
-- video url
|
||||||
|
Loading…
Reference in New Issue
Block a user