normalize file name

This commit is contained in:
Antonio J. Delgado 2024-12-28 19:37:51 +02:00
parent d54da4b482
commit dce5c15604

View file

@ -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(