From cac26dae7ea5eac731fd3e820b1545c1c51b9871 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 11 Sep 2019 20:57:01 +0200 Subject: [PATCH] Notify if no videos are found --- royalnet/audio/ytdlinfo.py | 7 ++++++- royalnet/bots/generic.py | 3 +++ royalnet/commands/royalgames/play.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/royalnet/audio/ytdlinfo.py b/royalnet/audio/ytdlinfo.py index 739b086a..c42d01dc 100644 --- a/royalnet/audio/ytdlinfo.py +++ b/royalnet/audio/ytdlinfo.py @@ -93,7 +93,12 @@ class YtdlInfo: return [] # If it is a playlist, create multiple videos! if "entries" in first_info: - return [YtdlInfo(second_info) for second_info in first_info["entries"]] + second_info_list = [] + for second_info in first_info["entries"]: + if second_info is None: + continue + second_info_list.append(YtdlInfo(second_info)) + return second_info_list return [YtdlInfo(first_info)] def to_discord_embed(self) -> discord.Embed: diff --git a/royalnet/bots/generic.py b/royalnet/bots/generic.py index 34adbc30..c97753b0 100644 --- a/royalnet/bots/generic.py +++ b/royalnet/bots/generic.py @@ -99,6 +99,9 @@ class GenericBot: response: Response = await getattr(network_handler, self.interface_name)(self, request.data) return response.to_dict() except Exception: + if __debug__: + raise + exit(1) _, exc, _ = sys.exc_info() log.debug(f"Exception {exc} in {network_handler}") return ResponseError("exception_in_handler", diff --git a/royalnet/commands/royalgames/play.py b/royalnet/commands/royalgames/play.py index 1586bf7e..e397020d 100644 --- a/royalnet/commands/royalgames/play.py +++ b/royalnet/commands/royalgames/play.py @@ -67,6 +67,8 @@ class PlayCommand(Command): async def run(self, args: CommandArgs, data: CommandData) -> None: guild_name, url = args.match(r"(?:\[(.+)])?\s*?") response = await self.interface.net_request(Request("music_play", {"url": url, "guild_name": guild_name}), "discord") + if len(response["videos"]) == 0: + await data.reply(f"⚠️ Nessun video trovato.") for video in response["videos"]: if self.interface.name == "discord": # This is one of the unsafest things ever