1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Don't crash if no videos are returned by a search

This commit is contained in:
Steffo 2019-09-10 13:53:07 +02:00
parent 3138250c7f
commit 20e0a86fb7

View file

@ -88,6 +88,9 @@ class YtdlInfo:
# So many redundant options! # So many redundant options!
ytdl = youtube_dl.YoutubeDL({**cls._default_ytdl_args, **ytdl_args}) ytdl = youtube_dl.YoutubeDL({**cls._default_ytdl_args, **ytdl_args})
first_info = ytdl.extract_info(url=url, download=False) first_info = ytdl.extract_info(url=url, download=False)
# No video was found
if first_info is None:
return []
# If it is a playlist, create multiple videos! # If it is a playlist, create multiple videos!
if "entries" in first_info: if "entries" in first_info:
return [YtdlInfo(second_info) for second_info in first_info["entries"]] return [YtdlInfo(second_info) for second_info in first_info["entries"]]