add hook
This commit is contained in:
parent
f922e835e3
commit
de762a5533
1 changed files with 17 additions and 2 deletions
|
@ -130,7 +130,7 @@ class GetPeertubeVideos:
|
||||||
selected['url'],
|
selected['url'],
|
||||||
full_file_name
|
full_file_name
|
||||||
)
|
)
|
||||||
result = self.session.get(selected['url'])
|
result = self.session.get(selected['url'], hooks={'response': self._req_hook})
|
||||||
video_bytes = result.content
|
video_bytes = result.content
|
||||||
with open(full_file_name, mode='wb') as video_file:
|
with open(full_file_name, mode='wb') as video_file:
|
||||||
video_file.write(video_bytes)
|
video_file.write(video_bytes)
|
||||||
|
@ -174,11 +174,26 @@ class GetPeertubeVideos:
|
||||||
'-disposition:0', 'attached_pic', f"{video_file}_with_thumb"
|
'-disposition:0', 'attached_pic', f"{video_file}_with_thumb"
|
||||||
],
|
],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
check=True
|
check=False
|
||||||
|
)
|
||||||
|
if result.returncode != 0:
|
||||||
|
self._log.error(
|
||||||
|
"Error %s adding thumnail. Output: %s. Errors: %s",
|
||||||
|
result.returncode,
|
||||||
|
result.stdout,
|
||||||
|
result.stderr
|
||||||
)
|
)
|
||||||
os.remove(video_file)
|
os.remove(video_file)
|
||||||
os.rename(f"{video_file}_with_thumb", 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):
|
def _write_downloaded_items(self):
|
||||||
with open(self.config['downloaded_database'], 'w', encoding='utf-8') as db_file:
|
with open(self.config['downloaded_database'], 'w', encoding='utf-8') as db_file:
|
||||||
for download_item in self.downloaded_items:
|
for download_item in self.downloaded_items:
|
||||||
|
|
Loading…
Reference in a new issue