diff --git a/cogs/ytdl.py b/cogs/ytdl.py index a3855a6..63ecb71 100644 --- a/cogs/ytdl.py +++ b/cogs/ytdl.py @@ -1,7 +1,7 @@ import os import subprocess -from discord.ext import commands +from discord.ext import commands, tasks from cogs.base_cog.bot_base_cog import BotBaseCog class YoutubeDL(BotBaseCog): @@ -22,6 +22,14 @@ class YoutubeDL(BotBaseCog): await ctx.send(f"Downloaded {video_or_audio} from {url}, output: {output}") except: await ctx.send("Usage: !youtubedl ") + + #create a task + @tasks.loop(seconds=10) + async def check_for_downloads(self): + for file in os.listdir("data/ytdl"): + if file.endswith(".txt"): + await self.bot.get_channel(544408659174883328).send(f"{file[:-4]}") + os.remove(f"data/ytdl/{file}") async def setup(bot): await bot.add_cog(YoutubeDL(bot)) \ No newline at end of file diff --git a/data/ytdl/youtubedl.py b/data/ytdl/youtubedl.py index 2769e2c..409d5f9 100644 --- a/data/ytdl/youtubedl.py +++ b/data/ytdl/youtubedl.py @@ -45,10 +45,11 @@ def main(): zip_file = zip_all_files() output_url = upload_to_litterbox(zip_file) print(output_url) - return output_url + with open(f"data/ytdl/{output_url}.txt", "w") as output_file: + output_file.write(output_url) + output_file.close() else: print("Invalid argument") - return 1 if __name__ == "__main__": main()