mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[cleanup] Misc fixes (see desc)
* Do not warn when fixup is skipped for existing file
* [fragment] Fix `--skip-unavailable-fragments` for HTTP Errors
* [utils] write_string: Fix bug in 59f943cd50
* [utils] parse_codecs: Subtitle codec is generally referred to as `scodec`. https://github.com/yt-dlp/yt-dlp/pull/2174#discussion_r790156048
* [docs] Remove note about permissions. Closes #3597
This commit is contained in:
parent
6f7563beb7
commit
3fe75fdc80
|
@ -320,9 +320,7 @@ # USAGE AND OPTIONS
|
||||||
## General Options:
|
## General Options:
|
||||||
-h, --help Print this help text and exit
|
-h, --help Print this help text and exit
|
||||||
--version Print program version and exit
|
--version Print program version and exit
|
||||||
-U, --update Update this program to latest version. Make
|
-U, --update Update this program to latest version
|
||||||
sure that you have sufficient permissions
|
|
||||||
(run with sudo if needed)
|
|
||||||
-i, --ignore-errors Ignore download and postprocessing errors.
|
-i, --ignore-errors Ignore download and postprocessing errors.
|
||||||
The download will be considered successful
|
The download will be considered successful
|
||||||
even if the postprocessing fails
|
even if the postprocessing fails
|
||||||
|
|
|
@ -3151,16 +3151,16 @@ def fixup():
|
||||||
if fixup_policy in ('ignore', 'never'):
|
if fixup_policy in ('ignore', 'never'):
|
||||||
return
|
return
|
||||||
elif fixup_policy == 'warn':
|
elif fixup_policy == 'warn':
|
||||||
do_fixup = False
|
do_fixup = 'warn'
|
||||||
elif fixup_policy != 'force':
|
elif fixup_policy != 'force':
|
||||||
assert fixup_policy in ('detect_or_warn', None)
|
assert fixup_policy in ('detect_or_warn', None)
|
||||||
if not info_dict.get('__real_download'):
|
if not info_dict.get('__real_download'):
|
||||||
do_fixup = False
|
do_fixup = False
|
||||||
|
|
||||||
def ffmpeg_fixup(cndn, msg, cls):
|
def ffmpeg_fixup(cndn, msg, cls):
|
||||||
if not cndn:
|
if not (do_fixup and cndn):
|
||||||
return
|
return
|
||||||
if not do_fixup:
|
elif do_fixup == 'warn':
|
||||||
self.report_warning(f'{vid}: {msg}')
|
self.report_warning(f'{vid}: {msg}')
|
||||||
return
|
return
|
||||||
pp = cls(self)
|
pp = cls(self)
|
||||||
|
|
|
@ -123,7 +123,7 @@ def _download_fragment(self, ctx, frag_url, info_dict, headers=None, request_dat
|
||||||
'request_data': request_data,
|
'request_data': request_data,
|
||||||
'ctx_id': ctx.get('ctx_id'),
|
'ctx_id': ctx.get('ctx_id'),
|
||||||
}
|
}
|
||||||
success = ctx['dl'].download(fragment_filename, fragment_info_dict)
|
success, _ = ctx['dl'].download(fragment_filename, fragment_info_dict)
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
if fragment_info_dict.get('filetime'):
|
if fragment_info_dict.get('filetime'):
|
||||||
|
|
|
@ -2808,7 +2808,7 @@ def extract_Initialization(source):
|
||||||
content_type = 'video'
|
content_type = 'video'
|
||||||
elif codecs['acodec'] != 'none':
|
elif codecs['acodec'] != 'none':
|
||||||
content_type = 'audio'
|
content_type = 'audio'
|
||||||
elif codecs.get('tcodec', 'none') != 'none':
|
elif codecs.get('scodec', 'none') != 'none':
|
||||||
content_type = 'text'
|
content_type = 'text'
|
||||||
elif mimetype2ext(mime_type) in ('tt', 'dfxp', 'ttml', 'xml', 'json'):
|
elif mimetype2ext(mime_type) in ('tt', 'dfxp', 'ttml', 'xml', 'json'):
|
||||||
content_type = 'text'
|
content_type = 'text'
|
||||||
|
|
|
@ -236,7 +236,7 @@ def _dict_from_options_callback(
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'-U', '--update',
|
'-U', '--update',
|
||||||
action='store_true', dest='update_self',
|
action='store_true', dest='update_self',
|
||||||
help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
|
help='Update this program to latest version')
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'-i', '--ignore-errors',
|
'-i', '--ignore-errors',
|
||||||
action='store_true', dest='ignoreerrors',
|
action='store_true', dest='ignoreerrors',
|
||||||
|
|
|
@ -1859,7 +1859,7 @@ def write_string(s, out=None, encoding=None):
|
||||||
|
|
||||||
from .compat import WINDOWS_VT_MODE # Must be imported locally
|
from .compat import WINDOWS_VT_MODE # Must be imported locally
|
||||||
if WINDOWS_VT_MODE:
|
if WINDOWS_VT_MODE:
|
||||||
s = s.replace('\n', ' \n')
|
s = re.sub(r'([\r\n]+)', r' \1', s)
|
||||||
|
|
||||||
if 'b' in getattr(out, 'mode', ''):
|
if 'b' in getattr(out, 'mode', ''):
|
||||||
byt = s.encode(encoding or preferredencoding(), 'ignore')
|
byt = s.encode(encoding or preferredencoding(), 'ignore')
|
||||||
|
@ -3177,7 +3177,7 @@ def parse_codecs(codecs_str):
|
||||||
return {}
|
return {}
|
||||||
split_codecs = list(filter(None, map(
|
split_codecs = list(filter(None, map(
|
||||||
str.strip, codecs_str.strip().strip(',').split(','))))
|
str.strip, codecs_str.strip().strip(',').split(','))))
|
||||||
vcodec, acodec, tcodec, hdr = None, None, None, None
|
vcodec, acodec, scodec, hdr = None, None, None, None
|
||||||
for full_codec in split_codecs:
|
for full_codec in split_codecs:
|
||||||
parts = full_codec.split('.')
|
parts = full_codec.split('.')
|
||||||
codec = parts[0].replace('0', '')
|
codec = parts[0].replace('0', '')
|
||||||
|
@ -3195,16 +3195,16 @@ def parse_codecs(codecs_str):
|
||||||
if not acodec:
|
if not acodec:
|
||||||
acodec = full_codec
|
acodec = full_codec
|
||||||
elif codec in ('stpp', 'wvtt',):
|
elif codec in ('stpp', 'wvtt',):
|
||||||
if not tcodec:
|
if not scodec:
|
||||||
tcodec = full_codec
|
scodec = full_codec
|
||||||
else:
|
else:
|
||||||
write_string(f'WARNING: Unknown codec {full_codec}\n')
|
write_string(f'WARNING: Unknown codec {full_codec}\n')
|
||||||
if vcodec or acodec or tcodec:
|
if vcodec or acodec or scodec:
|
||||||
return {
|
return {
|
||||||
'vcodec': vcodec or 'none',
|
'vcodec': vcodec or 'none',
|
||||||
'acodec': acodec or 'none',
|
'acodec': acodec or 'none',
|
||||||
'dynamic_range': hdr,
|
'dynamic_range': hdr,
|
||||||
**({'tcodec': tcodec} if tcodec is not None else {}),
|
**({'scodec': scodec} if scodec is not None else {}),
|
||||||
}
|
}
|
||||||
elif len(split_codecs) == 2:
|
elif len(split_codecs) == 2:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue