Save thumb and remove hook
This commit is contained in:
parent
de762a5533
commit
9fd5352f2d
1 changed files with 11 additions and 9 deletions
|
@ -130,8 +130,11 @@ class GetPeertubeVideos:
|
|||
selected['url'],
|
||||
full_file_name
|
||||
)
|
||||
result = self.session.get(selected['url'], hooks={'response': self._req_hook})
|
||||
result = self.session.get(selected['url'])
|
||||
video_bytes = result.content
|
||||
self._log.debug(
|
||||
'Saving video to file...'
|
||||
)
|
||||
with open(full_file_name, mode='wb') as video_file:
|
||||
video_file.write(video_bytes)
|
||||
sel_thumb = ''
|
||||
|
@ -142,6 +145,13 @@ class GetPeertubeVideos:
|
|||
split_url = sel_thumb['url'].split('.')
|
||||
thumb_file_name = file_name.replace(file_extension, split_url[len(split_url)-1])
|
||||
full_thumb_file_name = os.path.join(self.config['download_dir'], thumb_file_name)
|
||||
result = self.session.get(sel_thumb['url'])
|
||||
thumb_bytes = result.content
|
||||
self._log.debug(
|
||||
'Saving thumbnail to file...'
|
||||
)
|
||||
with open(full_thumb_file_name, mode='wb') as thumb_file:
|
||||
thumb_file.write(thumb_bytes)
|
||||
self._add_thumbnail_to_video(full_file_name, full_thumb_file_name)
|
||||
else:
|
||||
self._log.debug(
|
||||
|
@ -186,14 +196,6 @@ class GetPeertubeVideos:
|
|||
os.remove(video_file)
|
||||
os.rename(f"{video_file}_with_thumb", video_file)
|
||||
|
||||
def _req_hook(self, request, *args, **kwargs):
|
||||
self._log.debug(
|
||||
"Request hook: %s. Other args: %s. Dictionary args: %s",
|
||||
request,
|
||||
args,
|
||||
kwargs
|
||||
)
|
||||
|
||||
def _write_downloaded_items(self):
|
||||
with open(self.config['downloaded_database'], 'w', encoding='utf-8') as db_file:
|
||||
for download_item in self.downloaded_items:
|
||||
|
|
Loading…
Reference in a new issue