1
0
Fork 0

[cleanup] Misc cleanup

This commit is contained in:
pukkandan 2022-07-09 01:07:47 +05:30
commit f2df407165
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
19 changed files with 52 additions and 38 deletions

View file

@ -3198,8 +3198,8 @@ class YoutubeDL:
if not postprocessed_by_ffmpeg:
ffmpeg_fixup(ext == 'm4a' and info_dict.get('container') == 'm4a_dash',
'writing DASH m4a. Only some players support this container',
FFmpegFixupM4aPP)
'writing DASH m4a. Only some players support this container',
FFmpegFixupM4aPP)
ffmpeg_fixup(downloader == 'hlsnative' and not self.params.get('hls_use_mpegts')
or info_dict.get('is_live') and self.params.get('hls_use_mpegts') is None,
'Possible MPEG-TS in MP4 container or malformed AAC timestamps',

View file

@ -2,6 +2,7 @@ f'You are using an unsupported version of Python. Only Python versions 3.6 and a
__license__ = 'Public Domain'
import collections
import getpass
import itertools
import optparse
@ -516,7 +517,7 @@ def validate_options(opts):
# Do not unnecessarily download audio
opts.format = 'bestaudio/best'
if opts.getcomments and opts.writeinfojson is None:
if opts.getcomments and opts.writeinfojson is None and not opts.embed_infojson:
# If JSON is not printed anywhere, but comments are requested, save it to file
if not opts.dumpjson or opts.print_json or opts.dump_single_json:
opts.writeinfojson = True
@ -665,8 +666,11 @@ def get_postprocessors(opts):
}
ParsedOptions = collections.namedtuple('ParsedOptions', ('parser', 'options', 'urls', 'ydl_opts'))
def parse_options(argv=None):
""" @returns (parser, opts, urls, ydl_opts) """
"""@returns ParsedOptions(parser, opts, urls, ydl_opts)"""
parser, opts, urls = parseOpts(argv)
urls = get_urls(urls, opts.batchfile, opts.verbose)
@ -690,7 +694,7 @@ def parse_options(argv=None):
else opts.audioformat if (opts.extractaudio and opts.audioformat in FFmpegExtractAudioPP.SUPPORTED_EXTS)
else None)
return parser, opts, urls, {
return ParsedOptions(parser, opts, urls, {
'usenetrc': opts.usenetrc,
'netrc_location': opts.netrc_location,
'username': opts.username,
@ -863,7 +867,7 @@ def parse_options(argv=None):
'_warnings': warnings,
'_deprecation_warnings': deprecation_warnings,
'compat_opts': opts.compat_opts,
}
})
def _real_main(argv=None):

View file

@ -428,9 +428,9 @@ def create_parser():
action='store_false', dest='mark_watched',
help='Do not mark videos watched (default)')
general.add_option(
'--no-colors',
'--no-colors', '--no-colours',
action='store_true', dest='no_color', default=False,
help='Do not emit color codes in output')
help='Do not emit color codes in output (Alias: --no-colours)')
general.add_option(
'--compat-options',
metavar='OPTS', dest='compat_opts', default=set(), type='str',

View file

@ -725,11 +725,10 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
value = value.replace('\0', '') # nul character cannot be passed in command line
metadata['common'].update({meta_f: value for meta_f in variadic(meta_list)})
# See [1-4] for some info on media metadata/metadata supported
# by ffmpeg.
# 1. https://kdenlive.org/en/project/adding-meta-data-to-mp4-video/
# 2. https://wiki.multimedia.cx/index.php/FFmpeg_Metadata
# 3. https://kodi.wiki/view/Video_file_tagging
# Info on media metadata/metadata supported by ffmpeg:
# https://wiki.multimedia.cx/index.php/FFmpeg_Metadata
# https://kdenlive.org/en/project/adding-meta-data-to-mp4-video/
# https://kodi.wiki/view/Video_file_tagging
add('title', ('track', 'title'))
add('date', 'upload_date')

View file

@ -1908,6 +1908,10 @@ class DateRange:
def __str__(self):
return f'{self.start.isoformat()} - {self.end.isoformat()}'
def __eq__(self, other):
return (isinstance(other, DateRange)
and self.start == other.start and self.end == other.end)
def platform_name():
""" Returns the platform name as a str """
@ -2660,7 +2664,7 @@ class LazyList(collections.abc.Sequence):
@staticmethod
def _reverse_index(x):
return None if x is None else -(x + 1)
return None if x is None else ~x
def __getitem__(self, idx):
if isinstance(idx, slice):
@ -3662,21 +3666,26 @@ def match_filter_func(filters):
return _match_func
def download_range_func(chapters, ranges):
def inner(info_dict, ydl):
class download_range_func:
def __init__(self, chapters, ranges):
self.chapters, self.ranges = chapters, ranges
def __call__(self, info_dict, ydl):
warning = ('There are no chapters matching the regex' if info_dict.get('chapters')
else 'Cannot match chapters since chapter information is unavailable')
for regex in chapters or []:
for regex in self.chapters or []:
for i, chapter in enumerate(info_dict.get('chapters') or []):
if re.search(regex, chapter['title']):
warning = None
yield {**chapter, 'index': i}
if chapters and warning:
if self.chapters and warning:
ydl.to_screen(f'[info] {info_dict["id"]}: {warning}')
yield from ({'start_time': start, 'end_time': end} for start, end in ranges or [])
yield from ({'start_time': start, 'end_time': end} for start, end in self.ranges or [])
return inner
def __eq__(self, other):
return (isinstance(other, download_range_func)
and self.chapters == other.chapters and self.ranges == other.ranges)
def parse_dfxp_time_expr(time_expr):