diff --git a/royalnet/commands/royalgames/play.py b/royalnet/commands/royalgames/play.py index ab1b96ea..1586bf7e 100644 --- a/royalnet/commands/royalgames/play.py +++ b/royalnet/commands/royalgames/play.py @@ -1,5 +1,6 @@ import typing import pickle +import datetime from ..command import Command from ..commandinterface import CommandInterface from ..commandargs import CommandArgs @@ -15,11 +16,6 @@ if typing.TYPE_CHECKING: class PlayNH(NetworkHandler): message_type = "music_play" - ytdl_args = { - "format": "bestaudio", - "outtmpl": f"./downloads/%(title)s.%(ext)s" - } - @classmethod async def discord(cls, bot: "DiscordBot", data: dict): """Handle a play Royalnet request. That is, add audio to a PlayMode.""" @@ -36,11 +32,16 @@ class PlayNH(NetworkHandler): if not bot.music_data.get(guild): # TODO: change Exception raise Exception("No music_data for this guild") + # Create url + ytdl_args = { + "format": "bestaudio", + "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" + } # Start downloading if data["url"].startswith("http://") or data["url"].startswith("https://"): - dfiles: typing.List[YtdlDiscord] = await asyncify(YtdlDiscord.create_and_ready_from_url, data["url"], **cls.ytdl_args) + dfiles: typing.List[YtdlDiscord] = await asyncify(YtdlDiscord.create_and_ready_from_url, data["url"], **ytdl_args) else: - dfiles = await asyncify(YtdlDiscord.create_and_ready_from_url, f"ytsearch:{data['url']}", **cls.ytdl_args) + dfiles = await asyncify(YtdlDiscord.create_and_ready_from_url, f"ytsearch:{data['url']}", **ytdl_args) await bot.add_to_music_data(dfiles, guild) # Create response dictionary response = { diff --git a/royalnet/commands/royalgames/zawarudo.py b/royalnet/commands/royalgames/zawarudo.py index e12f5910..d0941427 100644 --- a/royalnet/commands/royalgames/zawarudo.py +++ b/royalnet/commands/royalgames/zawarudo.py @@ -1,6 +1,7 @@ import typing import discord import asyncio +import datetime from ..command import Command from ..commandinterface import CommandInterface from ..commandargs import CommandArgs @@ -37,13 +38,18 @@ class ZawarudoNH(NetworkHandler): if not bot.music_data.get(guild): # TODO: change Exception raise Exception("No music_data for this guild") + # Create url + ytdl_args = { + "format": "bestaudio", + "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" + } # Start downloading zw_start: typing.List[YtdlDiscord] = await asyncify(YtdlDiscord.create_and_ready_from_url, "https://scaleway.steffo.eu/jojo/zawarudo_intro.mp3", - **cls.ytdl_args) + **ytdl_args) zw_end: typing.List[YtdlDiscord] = await asyncify(YtdlDiscord.create_and_ready_from_url, "https://scaleway.steffo.eu/jojo/zawarudo_outro.mp3", - **cls.ytdl_args) + **ytdl_args) old_playlist = bot.music_data[guild] bot.music_data[guild] = Playlist() # Get voice client