From 3fc4c0475dc90351e4ff722573232496bf6ac2bd Mon Sep 17 00:00:00 2001 From: phixxy Date: Wed, 4 Sep 2024 19:39:30 -0700 Subject: [PATCH] fixed error in retreiving litterbox link --- cogs/ytdl.py | 10 +++++++++- data/ytdl/youtubedl.py | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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()