[cleanup] Refactor __init__.py (#2570)

* Split `__init__` code into multiple functions
* Clean up validation code by grouping similar types of options
* Expose `parse_options` to third parties
This commit is contained in:
pukkandan 2022-03-09 01:33:31 +05:30 committed by GitHub
parent 1eae7f94c1
commit d1b5f70bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 486 additions and 467 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1182,7 +1182,7 @@ def _dict_from_options_callback(
help='Do not write video description (default)') help='Do not write video description (default)')
filesystem.add_option( filesystem.add_option(
'--write-info-json', '--write-info-json',
action='store_true', dest='writeinfojson', default=False, action='store_true', dest='writeinfojson', default=None,
help='Write video metadata to a .info.json file (this may contain personal information)') help='Write video metadata to a .info.json file (this may contain personal information)')
filesystem.add_option( filesystem.add_option(
'--no-write-info-json', '--no-write-info-json',

View File

@ -404,7 +404,7 @@ def _concat_spec(cls, in_files, concat_opts=None):
class FFmpegExtractAudioPP(FFmpegPostProcessor): class FFmpegExtractAudioPP(FFmpegPostProcessor):
COMMON_AUDIO_EXTS = ('wav', 'flac', 'm4a', 'aiff', 'mp3', 'ogg', 'mka', 'opus', 'wma') COMMON_AUDIO_EXTS = ('wav', 'flac', 'm4a', 'aiff', 'mp3', 'ogg', 'mka', 'opus', 'wma')
SUPPORTED_EXTS = ('best', 'aac', 'flac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav', 'alac') SUPPORTED_EXTS = ('aac', 'flac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav', 'alac')
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False): def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
FFmpegPostProcessor.__init__(self, downloader) FFmpegPostProcessor.__init__(self, downloader)

View File

@ -3603,6 +3603,9 @@ def match_str(filter_str, dct, incomplete=False):
def match_filter_func(filter_str): def match_filter_func(filter_str):
if filter_str is None:
return None
def _match_func(info_dict, *args, **kwargs): def _match_func(info_dict, *args, **kwargs):
if match_str(filter_str, info_dict, *args, **kwargs): if match_str(filter_str, info_dict, *args, **kwargs):
return None return None