From dce5c156047862d2986a23680f840cc21347781c Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Sat, 28 Dec 2024 19:37:51 +0200 Subject: [PATCH] normalize file name --- get_peertube_videos/get_peertube_videos.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/get_peertube_videos/get_peertube_videos.py b/get_peertube_videos/get_peertube_videos.py index b50d0b5..c3f4c84 100644 --- a/get_peertube_videos/get_peertube_videos.py +++ b/get_peertube_videos/get_peertube_videos.py @@ -122,15 +122,16 @@ class GetPeertubeVideos: self._write_downloaded_items() elif 'video' in selected['type']: file_extension = selected['type'].replace('video/', '.') - file_name = os.path.join(self.config['download_dir'], f"{item['title']}{file_extension}") + file_name = os.path.normpath(f"{item['title']}{file_extension}").replace('\\', '-').replace('/', '-').replace(':', '.') + full_file_name = os.path.join(self.config['download_dir'], file_name) self._log.info( "Downloading video '%s' as '%s'...", selected['url'], - file_name + full_file_name ) result = self.session.get(selected['url']) video_bytes = result.content - with open(file_name, mode='wb') as video_file: + with open(full_file_name, mode='wb') as video_file: video_file.write(video_bytes) else: self._log.debug(