aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-07-09 01:07:47 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-07-09 09:07:10 +0530
commitf2df4071651d124bf7bad47648a6eb7a9ce57369 (patch)
treea9077290f3fae5060e62453fe41dadd19d161d32 /yt_dlp
parentca9def714a71151bec9e16ae0042a2c49f9ec99c (diff)
downloadhypervideo-pre-f2df4071651d124bf7bad47648a6eb7a9ce57369.tar.lz
hypervideo-pre-f2df4071651d124bf7bad47648a6eb7a9ce57369.tar.xz
hypervideo-pre-f2df4071651d124bf7bad47648a6eb7a9ce57369.zip
[cleanup] Misc cleanup
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/YoutubeDL.py4
-rw-r--r--yt_dlp/__init__.py12
-rw-r--r--yt_dlp/options.py4
-rw-r--r--yt_dlp/postprocessor/ffmpeg.py9
-rw-r--r--yt_dlp/utils.py23
5 files changed, 32 insertions, 20 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index f38a885ae..bbeb48d54 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -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',
diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py
index 357be861b..fd44e1ab9 100644
--- a/yt_dlp/__init__.py
+++ b/yt_dlp/__init__.py
@@ -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):
diff --git a/yt_dlp/options.py b/yt_dlp/options.py
index 386e8308e..1e23e2b98 100644
--- a/yt_dlp/options.py
+++ b/yt_dlp/options.py
@@ -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',
diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py
index 2d16ee351..67daf4424 100644
--- a/yt_dlp/postprocessor/ffmpeg.py
+++ b/yt_dlp/postprocessor/ffmpeg.py
@@ -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')
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index c2e766ce4..fe7520bd3 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -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):