Use next_progress to avoid logging in spurts
This commit is contained in:
1 parent
3c4849551b
commit
09812019b5
1 file changed
+8
-2
@@ -13,6 +13,7 @@ postprocessor_hook = {
|
|||||||
'status': dict(),
|
'status': dict(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BaseStatus:
|
class BaseStatus:
|
||||||
valid = set()
|
valid = set()
|
||||||
|
|
||||||
@@ -55,6 +56,11 @@ class ProgressHookStatus(BaseStatus):
|
|||||||
self.status = status
|
self.status = status
|
||||||
self.download_progress = 0
|
self.download_progress = 0
|
||||||
|
|
||||||
|
def next_progress(self):
|
||||||
|
if 0 == self.download_progress:
|
||||||
|
return 0
|
||||||
|
return 5 + self.download_progress
|
||||||
|
|
||||||
class PPHookStatus(BaseStatus):
|
class PPHookStatus(BaseStatus):
|
||||||
valid = frozenset((
|
valid = frozenset((
|
||||||
'started',
|
'started',
|
||||||
@@ -109,10 +115,10 @@ def yt_dlp_progress_hook(event):
|
|||||||
pass
|
pass
|
||||||
if downloaded_bytes > 0 and total_bytes > 0:
|
if downloaded_bytes > 0 and total_bytes > 0:
|
||||||
percent = round(100 * downloaded_bytes / total_bytes)
|
percent = round(100 * downloaded_bytes / total_bytes)
|
||||||
if percent and (0 < percent) and (0 == percent % 5):
|
if percent and (self.next_progress() < percent) and (0 == percent % 5):
|
||||||
|
status.download_progress = percent
|
||||||
log.info(f'[youtube-dl] downloading: {filename} - {percent_str} '
|
log.info(f'[youtube-dl] downloading: {filename} - {percent_str} '
|
||||||
f'of {total} at {speed}, {eta} remaining')
|
f'of {total} at {speed}, {eta} remaining')
|
||||||
status.download_progress = percent or 0
|
|
||||||
elif 'finished' == event['status']:
|
elif 'finished' == event['status']:
|
||||||
# update the status for key to the finished value
|
# update the status for key to the finished value
|
||||||
status = ProgressHookStatus.get(key)
|
status = ProgressHookStatus.get(key)
|
||||||
|
|||||||
Reference in new issue
Block a user