Process download aside
This commit is contained in:
parent
8bf27630c7
commit
e94f2d9eed
1 changed files with 40 additions and 25 deletions
|
@ -202,7 +202,17 @@ class GetYoutubeVideos:
|
|||
}
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
try:
|
||||
ydl.download(uri)
|
||||
return_code = ydl.download(uri)
|
||||
self._process_download(
|
||||
{
|
||||
"return_code": return_code,
|
||||
'info_dict': {
|
||||
'id': video_id,
|
||||
},
|
||||
'filename': video_info.get('title', '?'),
|
||||
'video_info': video_info,
|
||||
}
|
||||
)
|
||||
except yt_dlp.utils.DownloadError as error:
|
||||
self._log.error(
|
||||
"Error getting video. %s",
|
||||
|
@ -227,8 +237,8 @@ class GetYoutubeVideos:
|
|||
self.summary['processed_channels'] = self.channels_count
|
||||
self.summary['total_count'] = self.total_count
|
||||
|
||||
def _yt_progress_hook(self, data):
|
||||
if data['status'] == 'finished':
|
||||
|
||||
def _process_download(self, data):
|
||||
self.total_count += 1
|
||||
self.channel_count += 1
|
||||
if self.total_count == self.config['total_limit']:
|
||||
|
@ -253,6 +263,11 @@ class GetYoutubeVideos:
|
|||
json.dump(data, info_file, indent=2)
|
||||
if 'id' in data['info_dict']:
|
||||
self._save_downloaded_items(data['info_dict']['id'])
|
||||
|
||||
|
||||
def _yt_progress_hook(self, data):
|
||||
if data['status'] == 'finished':
|
||||
self._process_download(data)
|
||||
elif data['status'] == 'downloading':
|
||||
downloading = True
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue