Compare commits

..

2 Commits

Author SHA1 Message Date
pk
93ec717757
Update yt_dlp/YoutubeDL.py
Oops!

Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2023-11-20 14:51:08 -06:00
pk
fe89d6aa4c
Redo NO_COLOR implimentation
Third time's a charm.
2023-11-20 14:37:03 -06:00

View File

@ -625,13 +625,16 @@ class YoutubeDL:
'Overwriting params from "color" with "no_color"')
self.params['color'] = 'no_color'
term_allow_color = os.getenv('TERM', '').lower() != 'dumb' and not os.getenv('NO_COLOR')
term_allow_color = os.getenv('TERM', '').lower() != 'dumb'
no_color = bool(os.getenv('NO_COLOR'))
def process_color_policy(stream):
stream_name = {sys.stdout: 'stdout', sys.stderr: 'stderr'}[stream]
policy = traverse_obj(self.params, ('color', (stream_name, None), {str}), get_all=False)
if policy in ('auto', None):
return term_allow_color and supports_terminal_sequences(stream)
if term_allow_color and supports_terminal_sequences(stream):
return 'no_color' if no_color else True
return False
assert policy in ('always', 'never', 'no_color'), policy
return {'always': True, 'never': False}.get(policy, policy)