From f7be30dcd802124c1bfa43198029f48df86208f7 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 29 Jan 2024 12:18:31 -0500 Subject: [PATCH] fix(youtubedownloader): fixed file not found error if the video name includes / or \ --- youtubedownloader/youtubedownloader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtubedownloader/youtubedownloader.py b/youtubedownloader/youtubedownloader.py index c68d84c..514b601 100644 --- a/youtubedownloader/youtubedownloader.py +++ b/youtubedownloader/youtubedownloader.py @@ -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')