normalize file name
This commit is contained in:
parent
d54da4b482
commit
dce5c15604
1 changed files with 4 additions and 3 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue