fix(youtubedownloader): fixed downloading the first video stream
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 53s
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 53s
This commit is contained in:
parent
af27593fa9
commit
229aaa77d5
1 changed files with 3 additions and 5 deletions
|
@ -67,18 +67,16 @@ class YouTubeDownloader(commands.Cog):
|
||||||
yt = YouTube(url=url)
|
yt = YouTube(url=url)
|
||||||
filename = f"{yt.title} ({yt.video_id})"
|
filename = f"{yt.title} ({yt.video_id})"
|
||||||
if audio_only:
|
if audio_only:
|
||||||
yt.streams.filter(only_audio=True, mime_type='audio/mp4')
|
stream = yt.streams.filter(only_audio=True, mime_type='audio/mp4').order_by('abr')
|
||||||
yt.streams.order_by('abr')
|
|
||||||
filename_format = filename + ".m4a"
|
filename_format = filename + ".m4a"
|
||||||
else:
|
else:
|
||||||
yt.streams.filter(progressive=True, mime_type="video/mp4")
|
stream = yt.streams.filter(progressive=True, mime_type='video/mp4').order_by('res')
|
||||||
yt.streams.order_by('resolution')
|
|
||||||
filename_format = filename + ".mp4"
|
filename_format = filename + ".mp4"
|
||||||
if os.path.isfile(path + f"{os.sep}{filename_format}"):
|
if os.path.isfile(path + f"{os.sep}{filename_format}"):
|
||||||
previously_existed = True
|
previously_existed = True
|
||||||
else:
|
else:
|
||||||
previously_existed = False
|
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()
|
data_path = await self.config.save_directory()
|
||||||
if subfolder and await self.bot.is_owner(ctx.author):
|
if subfolder and await self.bot.is_owner(ctx.author):
|
||||||
data_path = os.path.join(data_path, subfolder)
|
data_path = os.path.join(data_path, subfolder)
|
||||||
|
|
Loading…
Reference in a new issue