From 73679351d3dc1a2052ba10c6bd5e056f3cd7c917 Mon Sep 17 00:00:00 2001 From: phixxy Date: Wed, 4 Sep 2024 20:29:58 -0700 Subject: [PATCH] changed youtubedl.py to just assume cwd is wrong --- cogs/ytdl.py | 5 ++--- data/ytdl/youtubedl.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cogs/ytdl.py b/cogs/ytdl.py index 39185ca..e438c2d 100644 --- a/cogs/ytdl.py +++ b/cogs/ytdl.py @@ -16,9 +16,8 @@ class YoutubeDL(BotBaseCog): url = ctx.message.content.split(" ", 1)[1] url = '"' + url + '"' video_or_audio = ctx.message.content.split(" ", 2)[2] - working_dir = f"{os.getcwd()}/data/ytdl/" - process = subprocess.Popen(["python3", "data/ytdl/youtubedl.py", url, video_or_audio], cwd=working_dir) - await ctx.send(f"Downloading {video_or_audio} from {url}...", embeds=None) + process = subprocess.Popen(["python3", "data/ytdl/youtubedl.py", url, video_or_audio]) + await ctx.send(f"Downloading {video_or_audio} from {url}...", suppress_embeds=True) except: await ctx.send("Usage: !youtubedl ") diff --git a/data/ytdl/youtubedl.py b/data/ytdl/youtubedl.py index 409d5f9..33ed4bf 100644 --- a/data/ytdl/youtubedl.py +++ b/data/ytdl/youtubedl.py @@ -6,12 +6,12 @@ import subprocess def download(url, video_or_audio): if video_or_audio == "video": - process = subprocess.Popen(["yt-dlp", "--yes-playlist", f"{url}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(["yt-dlp", "-o", "data/ytdl/%(playlist|)s/%(playlist_index)s - %(title)s.%(ext)s", "--yes-playlist", f"{url}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(process.stdout.read()) process.wait() return True elif video_or_audio == "audio": - process = subprocess.Popen(["yt-dlp", "-x", "--yes-playlist", f"{url}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(["yt-dlp", "-o", "data/ytdl/%(playlist|)s/%(playlist_index)s - %(title)s.%(ext)s", "-x", "--yes-playlist", f"{url}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(process.stdout.read()) process.wait() return True @@ -23,7 +23,7 @@ def zip_all_files(): #zip all files current_epoch = time.time() output_file = f"{current_epoch}.zip" - os.system(f"zip -r {output_file} *") + os.system(f"zip -r {output_file} data/ytdl/*") return output_file def upload_to_litterbox(input_file):