mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 08:35:32 +00:00
[core] Support emitting ConEmu progress codes (#10649)
Authored by: Grub4K
This commit is contained in:
@ -8,6 +8,7 @@ import contextlib
|
||||
import datetime as dt
|
||||
import email.header
|
||||
import email.utils
|
||||
import enum
|
||||
import errno
|
||||
import functools
|
||||
import hashlib
|
||||
@ -5677,3 +5678,32 @@ class _YDLLogger:
|
||||
def stderr(self, message):
|
||||
if self._ydl:
|
||||
self._ydl.to_stderr(message)
|
||||
|
||||
|
||||
class _ProgressState(enum.Enum):
|
||||
"""
|
||||
Represents a state for a progress bar.
|
||||
|
||||
See: https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC
|
||||
"""
|
||||
|
||||
HIDDEN = 0
|
||||
INDETERMINATE = 3
|
||||
VISIBLE = 1
|
||||
WARNING = 4
|
||||
ERROR = 2
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, s, /):
|
||||
if s['status'] == 'finished':
|
||||
return cls.INDETERMINATE
|
||||
|
||||
# Not currently used
|
||||
if s['status'] == 'error':
|
||||
return cls.ERROR
|
||||
|
||||
return cls.INDETERMINATE if s.get('_percent') is None else cls.VISIBLE
|
||||
|
||||
def get_ansi_escape(self, /, percent=None):
|
||||
percent = 0 if percent is None else int(percent)
|
||||
return f'\033]9;4;{self.value};{percent}\007'
|
||||
|
Reference in New Issue
Block a user