]> jfr.im git - yt-dlp.git/commitdiff
[cleanup] Misc cleanup
authorpukkandan <redacted>
Fri, 8 Jul 2022 19:37:47 +0000 (01:07 +0530)
committerpukkandan <redacted>
Sat, 9 Jul 2022 03:37:10 +0000 (09:07 +0530)
19 files changed:
.github/ISSUE_TEMPLATE/1_broken_site.yml
.github/ISSUE_TEMPLATE/2_site_support_request.yml
.github/ISSUE_TEMPLATE/3_site_feature_request.yml
.github/ISSUE_TEMPLATE/4_bug_report.yml
.github/ISSUE_TEMPLATE/5_feature_request.yml
.github/ISSUE_TEMPLATE/6_question.yml
.github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml
.github/ISSUE_TEMPLATE_tmpl/2_site_support_request.yml
.github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.yml
.github/ISSUE_TEMPLATE_tmpl/4_bug_report.yml
.github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml
.github/ISSUE_TEMPLATE_tmpl/6_question.yml
README.md
test/test_YoutubeDL.py
yt_dlp/YoutubeDL.py
yt_dlp/__init__.py
yt_dlp/options.py
yt_dlp/postprocessor/ffmpeg.py
yt_dlp/utils.py

index b8e39881603ef9ca3ebe25588033ad768dc65139..727df0da1d9da8a3e1eb5611229cb1dfc105a148 100644 (file)
@@ -32,7 +32,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 5aeb0e326f4422286f98a2ba24d90214a21a99bb..4d4c0d8710aace502d885c4cfde66323a2aad902 100644 (file)
@@ -44,7 +44,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index b34abe6675cc34b627ecb9ab6f7db08cbd5abdf3..b4a39dc434137c2d1bcdff5e64c65603da1dc780 100644 (file)
@@ -40,7 +40,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 1ab854bb94c028782b90259d61686f6718999363..2ae00e8d07737ace058f6ec043306d528ed6bc86 100644 (file)
@@ -25,7 +25,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 72551022b5e7cd0218c9b8a3fd47964dbd4c729b..f1e20998ee1b5ab43ecd76e0bf68ba3641cac069 100644 (file)
@@ -23,7 +23,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 8ef02bd9af5d148d3aca81df3417e26962410d4e..6077e6d6085160cee86123986ce0aee7aed20c22 100644 (file)
@@ -29,7 +29,7 @@ body:
     id: question
     attributes:
       label: Please make sure the question is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information and as much context and examples as possible
     validations:
       required: true
index c6d7cd40bf4f3dd66002be1b296158f1ac13c2cc..35fae2be61538fb36e9efca7634cff2e7b1c6d9d 100644 (file)
@@ -32,7 +32,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 07f744589114a9bb79a29b23e87fb33e54b3f447..02125f77df1dc628521c36b2dec37b87b139b316 100644 (file)
@@ -44,7 +44,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index dfd07a9f852bd7b817a057a92f236de816c30d4a..154d4e35f691dc76dc8657f96468c1a8cf1e63e0 100644 (file)
@@ -40,7 +40,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index cffe06fe3bc148d0634d31bcec9f2462c56ce583..ed1464c131fb277ef54233f4c05232499c3f3be8 100644 (file)
@@ -25,7 +25,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index dc6709bcf6265ad199ada3e09cfaac5fd9a5eab5..6c0ecf386d7b1221c163cf0adce1ccdec6cc86e3 100644 (file)
@@ -23,7 +23,7 @@ body:
     id: description
     attributes:
       label: Provide a description that is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information, any suggested solutions, and as much context and examples as possible
     validations:
       required: true
index 8cb8bba52d70aa91ba8d0a75dc266188742ff2fd..1df4d41db96d48b515138188347cf45ef2b1c41d 100644 (file)
@@ -29,7 +29,7 @@ body:
     id: question
     attributes:
       label: Please make sure the question is worded well enough to be understood
-      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient)
+      description: See [is-the-description-of-the-issue-itself-sufficient](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-description-of-the-issue-itself-sufficient)
       placeholder: Provide any additional information and as much context and examples as possible
     validations:
       required: true
index 43137f23b47d8c914bbca28391ebae8306312c2c..47f589c49ee348f271fcf02eb8f2789b3d2c4a7d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -147,7 +147,7 @@ ### Differences in default behavior
 * Some private fields such as filenames are removed by default from the infojson. Use `--no-clean-infojson` or `--compat-options no-clean-infojson` to revert this
 * When `--embed-subs` and `--write-subs` are used together, the subtitles are written to disk and also embedded in the media file. You can use just `--embed-subs` to embed the subs and automatically delete the separate file. See [#630 (comment)](https://github.com/yt-dlp/yt-dlp/issues/630#issuecomment-893659460) for more info. `--compat-options no-keep-subs` can be used to revert this
 * `certifi` will be used for SSL root certificates, if installed. If you want to use system certificates (e.g. self-signed), use `--compat-options no-certifi`
-* youtube-dl tries to remove some superfluous punctuations from filenames. While this can sometimes be helpfull, it is often undesirable. So yt-dlp tries to keep the fields in the filenames as close to their original values as possible. You can use `--compat-options filename-sanitization` to revert to youtube-dl's behavior
+* youtube-dl tries to remove some superfluous punctuations from filenames. While this can sometimes be helpful, it is often undesirable. So yt-dlp tries to keep the fields in the filenames as close to their original values as possible. You can use `--compat-options filename-sanitization` to revert to youtube-dl's behavior
 
 For ease of use, a few more compat options are available:
 
@@ -238,7 +238,7 @@ #### Recommended
 :---|:---
 [yt-dlp](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp)|Platform-independent [zipimport](https://docs.python.org/3/library/zipimport.html) binary. Needs Python (recommended for **Linux/BSD**)
 [yt-dlp.exe](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe)|Windows (Win7 SP1+) standalone x64 binary (recommended for **Windows**)
-[yt-dlp_macos](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos)|MacOS (10.15+) standalone executable (recommended for **MacOS**)
+[yt-dlp_macos](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos)|Universal MacOS (10.15+) standalone executable (recommended for **MacOS**)
 
 #### Alternatives
 
@@ -246,8 +246,8 @@ #### Alternatives
 :---|:---
 [yt-dlp_x86.exe](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_x86.exe)|Windows (Vista SP2+) standalone x86 (32-bit) binary
 [yt-dlp_min.exe](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_min.exe)|Windows (Win7 SP1+) standalone x64 binary built with `py2exe`<br/> ([Not recommended](#standalone-py2exe-builds-windows))
-[yt-dlp_linux](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux)|UNIX standalone x64 binary
-[yt-dlp_linux.zip](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux.zip)|Unpackaged Unix executable (no auto-update)
+[yt-dlp_linux](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux)|Linux standalone x64 binary
+[yt-dlp_linux.zip](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux.zip)|Unpackaged Linux executable (no auto-update)
 [yt-dlp_win.zip](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_win.zip)|Unpackaged Windows executable (no auto-update)
 [yt-dlp_macos.zip](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos.zip)|Unpackaged MacOS (10.15+) executable (no auto-update)
 [yt-dlp_macos_legacy](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos_legacy)|MacOS (10.9+) standalone x64 executable
@@ -305,7 +305,7 @@ #### Deprecated
 
 To use or redistribute the dependencies, you must agree to their respective licensing terms.
 
-The Windows and MacOS standalone release binaries are built with the Python interpreter and the packages marked with **\*** included.
+The standalone release binaries are built with the Python interpreter and the packages marked with **\*** included.
 
 If you do not have the necessary dependencies for a task you are attempting, yt-dlp will warn you. All the currently available dependencies are visible at the top of the `--verbose` output
 
@@ -414,7 +414,8 @@ ## General Options:
     --no-wait-for-video             Do not wait for scheduled streams (default)
     --mark-watched                  Mark videos watched (even with --simulate)
     --no-mark-watched               Do not mark videos watched (default)
-    --no-colors                     Do not emit color codes in output
+    --no-colors                     Do not emit color codes in output (Alias:
+                                    --no-colours)
     --compat-options OPTS           Options that can help keep compatibility
                                     with youtube-dl or youtube-dlc
                                     configurations by reverting some of the
index 1eb3abc17f712213848d51699e7cc92dab2dcde9..3e6f7ec3fe9f5f4f1a70c710dea11e8946a0b69e 100644 (file)
@@ -1053,6 +1053,7 @@ def test_selection(params, expected_ids, evaluate_all=False):
                            for v in get_downloaded_info_dicts(params, entries)]
                 self.assertEqual(results, list(enumerate(zip(expected_ids, expected_ids))), f'Entries of {name} for {params}')
                 self.assertEqual(sorted(evaluated), expected_eval, f'Evaluation of {name} for {params}')
+
         test_selection({}, INDICES)
         test_selection({'playlistend': 20}, INDICES, True)
         test_selection({'playlistend': 2}, INDICES[:2])
index f38a885aebaed3fa1159c659db6bdeaa0c29415f..bbeb48d545df5aff40c07af9c70d29cc14022260 100644 (file)
@@ -3198,8 +3198,8 @@ def ffmpeg_fixup(cndn, msg, cls):
 
                     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',
index 357be861b4db5b64cce8f13f89e5cc745879ae10..fd44e1ab9636e18daed58d69e8c526db58f90224 100644 (file)
@@ -2,6 +2,7 @@
 
 __license__ = 'Public Domain'
 
+import collections
 import getpass
 import itertools
 import optparse
@@ -516,7 +517,7 @@ def report_deprecation(val, old, new=None):
         # 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):
index 386e8308e0c72a3fa66320a8372f2cfe63852857..1e23e2b98cda6327f751fbebd2c5ab77b1cbcc2a 100644 (file)
@@ -428,9 +428,9 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
         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',
index 2d16ee351bf46893aa3f79051f45c3837facbd2a..67daf442489bf30774b46e74df48b9eca26884d5 100644 (file)
@@ -725,11 +725,10 @@ def add(meta_list, info_list=None):
                 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')
index c2e766ce4194765050d47fdcbaf711d8fe4219b7..fe7520bd3f4ad8c9f20113ace539776fc08ea233 100644 (file)
@@ -1908,6 +1908,10 @@ def __contains__(self, date):
     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 @@ def exhaust(self):
 
     @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_func(info_dict, incomplete=False):
     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):