1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Notify if no videos are found

This commit is contained in:
Steffo 2019-09-11 20:57:01 +02:00
parent ac9626efba
commit cac26dae7e
3 changed files with 11 additions and 1 deletions

View file

@ -93,7 +93,12 @@ class YtdlInfo:
return [] 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"]] 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)] return [YtdlInfo(first_info)]
def to_discord_embed(self) -> discord.Embed: def to_discord_embed(self) -> discord.Embed:

View file

@ -99,6 +99,9 @@ class GenericBot:
response: Response = await getattr(network_handler, self.interface_name)(self, request.data) response: Response = await getattr(network_handler, self.interface_name)(self, request.data)
return response.to_dict() return response.to_dict()
except Exception: except Exception:
if __debug__:
raise
exit(1)
_, exc, _ = sys.exc_info() _, exc, _ = sys.exc_info()
log.debug(f"Exception {exc} in {network_handler}") log.debug(f"Exception {exc} in {network_handler}")
return ResponseError("exception_in_handler", return ResponseError("exception_in_handler",

View file

@ -67,6 +67,8 @@ class PlayCommand(Command):
async def run(self, args: CommandArgs, data: CommandData) -> None: async def run(self, args: CommandArgs, data: CommandData) -> None:
guild_name, url = args.match(r"(?:\[(.+)])?\s*<?(.+)>?") guild_name, url = args.match(r"(?:\[(.+)])?\s*<?(.+)>?")
response = await self.interface.net_request(Request("music_play", {"url": url, "guild_name": guild_name}), "discord") 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"]: for video in response["videos"]:
if self.interface.name == "discord": if self.interface.name == "discord":
# This is one of the unsafest things ever # This is one of the unsafest things ever