From 229aaa77d5f979e445fd7532de550d2bf7999678 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Tue, 24 Oct 2023 00:28:41 -0400 Subject: [PATCH] fix(youtubedownloader): fixed downloading the first video stream --- youtubedownloader/youtubedownloader.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/youtubedownloader/youtubedownloader.py b/youtubedownloader/youtubedownloader.py index a4a1aed..3460109 100644 --- a/youtubedownloader/youtubedownloader.py +++ b/youtubedownloader/youtubedownloader.py @@ -67,18 +67,16 @@ class YouTubeDownloader(commands.Cog): yt = YouTube(url=url) filename = f"{yt.title} ({yt.video_id})" if audio_only: - yt.streams.filter(only_audio=True, mime_type='audio/mp4') - yt.streams.order_by('abr') + stream = yt.streams.filter(only_audio=True, mime_type='audio/mp4').order_by('abr') filename_format = filename + ".m4a" else: - yt.streams.filter(progressive=True, mime_type="video/mp4") - yt.streams.order_by('resolution') + stream = yt.streams.filter(progressive=True, mime_type='video/mp4').order_by('res') filename_format = filename + ".mp4" if os.path.isfile(path + f"{os.sep}{filename_format}"): previously_existed = True else: previously_existed = False - return yt.streams.first().download(filename=filename, output_path=path), previously_existed, filename_format + return stream.first().download(filename=filename, output_path=path), previously_existed, filename_format data_path = await self.config.save_directory() if subfolder and await self.bot.is_owner(ctx.author): data_path = os.path.join(data_path, subfolder)