fix(youtubedownloader): fixed file not found error if the video name includes / or \
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 1m50s

This commit is contained in:
Seaswimmer 2024-01-29 12:18:31 -05:00
parent 4e4c16f278
commit f7be30dcd8
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -65,7 +65,8 @@ class YouTubeDownloader(commands.Cog):
def youtube_download(url: str, path: str):
"""This function does the actual downloading of the YouTube Video."""
yt = YouTube(url=url)
filename = f"{yt.title} ({yt.video_id})"
translation_table = dict.fromkeys(map(ord, r'<>:"/\|?*'), None)
filename = f"{yt.title.translate(translation_table)} ({yt.video_id})"
if audio_only:
stream = yt.streams.filter(only_audio=True, mime_type='audio/mp4')
stream = stream.order_by('abr')