aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-05-12 10:54:49 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-05-12 10:54:49 +0530
commit2e4585da92864741421bc6ea3260145333535aeb (patch)
treefe163fdcf83bc58068dea0e615d01b02044be305
parent8dcce6a89ca0dcb875fa1ba5f8a83cc244ceabcb (diff)
downloadhypervideo-pre-2e4585da92864741421bc6ea3260145333535aeb.tar.lz
hypervideo-pre-2e4585da92864741421bc6ea3260145333535aeb.tar.xz
hypervideo-pre-2e4585da92864741421bc6ea3260145333535aeb.zip
[cookies] Throttle progress-bar
Closes #3710
-rw-r--r--yt_dlp/cookies.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py
index c6edaebe4..1a51d6880 100644
--- a/yt_dlp/cookies.py
+++ b/yt_dlp/cookies.py
@@ -7,6 +7,7 @@ import struct
import subprocess
import sys
import tempfile
+import time
from datetime import datetime, timedelta, timezone
from enum import Enum, auto
from hashlib import pbkdf2_hmac
@@ -49,6 +50,14 @@ class YDLLogger:
if self._ydl:
self._ydl.report_error(message)
+ class ProgressBar(MultilinePrinter):
+ _DELAY, _timer = 0.1, 0
+
+ def print(self, message):
+ if time.time() - self._timer > self._DELAY:
+ self.print_at_line(f'[Cookies] {message}', 0)
+ self._timer = time.time()
+
def progress_bar(self):
"""Return a context manager with a print method. (Optional)"""
# Do not print to files/pipes, loggers, or when --no-progress is used
@@ -60,10 +69,7 @@ class YDLLogger:
return
except BaseException:
return
-
- printer = MultilinePrinter(file, preserve_output=False)
- printer.print = lambda message: printer.print_at_line(f'[Cookies] {message}', 0)
- return printer
+ return self.ProgressBar(file, preserve_output=False)
def _create_progress_bar(logger):