mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 20:55:52 +01:00
parent
8dcce6a89c
commit
2e4585da92
@ -7,6 +7,7 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from hashlib import pbkdf2_hmac
|
from hashlib import pbkdf2_hmac
|
||||||
@ -49,6 +50,14 @@ def error(self, message):
|
|||||||
if self._ydl:
|
if self._ydl:
|
||||||
self._ydl.report_error(message)
|
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):
|
def progress_bar(self):
|
||||||
"""Return a context manager with a print method. (Optional)"""
|
"""Return a context manager with a print method. (Optional)"""
|
||||||
# Do not print to files/pipes, loggers, or when --no-progress is used
|
# Do not print to files/pipes, loggers, or when --no-progress is used
|
||||||
@ -60,10 +69,7 @@ def progress_bar(self):
|
|||||||
return
|
return
|
||||||
except BaseException:
|
except BaseException:
|
||||||
return
|
return
|
||||||
|
return self.ProgressBar(file, preserve_output=False)
|
||||||
printer = MultilinePrinter(file, preserve_output=False)
|
|
||||||
printer.print = lambda message: printer.print_at_line(f'[Cookies] {message}', 0)
|
|
||||||
return printer
|
|
||||||
|
|
||||||
|
|
||||||
def _create_progress_bar(logger):
|
def _create_progress_bar(logger):
|
||||||
|
Loading…
Reference in New Issue
Block a user