1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-07 16:55:15 +00:00

[docs] Misc improvements

Closes #4987, Closes #4906, Closes #4919, Closes #4977, Closes #4979
This commit is contained in:
pukkandan
2022-09-22 01:37:44 +05:30
parent 8ca48a1a54
commit 2fa669f759
11 changed files with 44 additions and 34 deletions

View File

@@ -489,7 +489,7 @@ def validate_options(opts):
val1=opts.sponskrub and opts.sponskrub_cut)
# Conflicts with --allow-unplayable-formats
report_conflict('--add-metadata', 'addmetadata')
report_conflict('--embed-metadata', 'addmetadata')
report_conflict('--embed-chapters', 'addchapters')
report_conflict('--embed-info-json', 'embed_infojson')
report_conflict('--embed-subs', 'embedsubtitles')

View File

@@ -1236,7 +1236,7 @@ class InfoExtractor:
fatal, has_default = False, True
json_string = self._search_regex(
rf'{start_pattern}\s*(?P<json>{{\s*{contains_pattern}\s*}})\s*{end_pattern}',
rf'(?:{start_pattern})\s*(?P<json>{{\s*(?:{contains_pattern})\s*}})\s*(?:{end_pattern})',
string, name, group='json', fatal=fatal, default=None if has_default else NO_DEFAULT)
if not json_string:
return default

View File

@@ -1,11 +1,10 @@
from .common import InfoExtractor
from .common import InfoExtractor
from ..utils import (
ExtractorError,
smuggle_url,
str_or_none,
traverse_obj,
urlencode_postdata
urlencode_postdata,
)

View File

@@ -2623,8 +2623,8 @@ class GenericIE(InfoExtractor):
url, smuggled_data = unsmuggle_url(url, {})
force_videoid = None
is_intentional = smuggled_data and smuggled_data.get('to_generic')
if smuggled_data and 'force_videoid' in smuggled_data:
is_intentional = smuggled_data.get('to_generic')
if 'force_videoid' in smuggled_data:
force_videoid = smuggled_data['force_videoid']
video_id = force_videoid
else:

View File

@@ -557,8 +557,7 @@ class NiconicoPlaylistBaseIE(InfoExtractor):
}
def _call_api(self, list_id, resource, query):
"Implement this in child class"
pass
raise NotImplementedError('Must be implemented in subclasses')
@staticmethod
def _parse_owner(item):

View File

@@ -1820,14 +1820,14 @@ def create_parser():
val.replace(r'\,', ',').strip() for val in re.split(r'(?<!\\),', vals)])
extractor.add_option(
'--extractor-args',
metavar='KEY:ARGS', dest='extractor_args', default={}, type='str',
metavar='IE_KEY:ARGS', dest='extractor_args', default={}, type='str',
action='callback', callback=_dict_from_options_callback,
callback_kwargs={
'multiple_keys': False,
'process': lambda val: dict(
_extractor_arg_parser(*arg.split('=', 1)) for arg in val.split(';'))
}, help=(
'Pass these arguments to the extractor. See "EXTRACTOR ARGUMENTS" for details. '
'Pass ARGS arguments to the IE_KEY extractor. See "EXTRACTOR ARGUMENTS" for details. '
'You can use this option multiple times to give arguments for different extractors'))
extractor.add_option(
'--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest',

View File

@@ -591,9 +591,14 @@ class LenientJSONDecoder(json.JSONDecoder):
def decode(self, s):
if self.transform_source:
s = self.transform_source(s)
if self.ignore_extra:
return self.raw_decode(s.lstrip())[0]
return super().decode(s)
try:
if self.ignore_extra:
return self.raw_decode(s.lstrip())[0]
return super().decode(s)
except json.JSONDecodeError as e:
if e.pos is not None:
raise type(e)(f'{e.msg} in {s[e.pos-10:e.pos+10]!r}', s, e.pos)
raise
def sanitize_open(filename, open_mode):
@@ -762,7 +767,7 @@ def sanitized_Request(url, *args, **kwargs):
def expand_path(s):
"""Expand $ shell variables and ~"""
"""Expand shell variables and ~"""
return os.path.expandvars(compat_expanduser(s))

View File

@@ -140,7 +140,6 @@ class HeaderBlock(Block):
A WebVTT block that may only appear in the header part of the file,
i.e. before any cue blocks.
"""
pass