]> jfr.im git - yt-dlp.git/commitdiff
Minor bugfixes
authorpukkandan <redacted>
Mon, 1 Aug 2022 22:10:47 +0000 (03:40 +0530)
committerpukkandan <redacted>
Mon, 1 Aug 2022 22:22:23 +0000 (03:52 +0530)
yt_dlp/YoutubeDL.py
yt_dlp/__init__.py
yt_dlp/extractor/common.py
yt_dlp/extractor/commonmistakes.py
yt_dlp/extractor/funimation.py
yt_dlp/extractor/genericembeds.py
yt_dlp/extractor/twitch.py
yt_dlp/utils.py

index 14823a4c63ebde0d7f90b9e7925d5f23300a01c5..e72354becb9d697cd0ac09bd043ed128c294e02a 100644 (file)
     iri_to_uri,
     join_nonempty,
     locked_file,
+    make_archive_id,
     make_dir,
     make_HTTPS_handler,
     merge_headers,
@@ -1738,8 +1739,8 @@ def __process_playlist(self, ie_result, download):
             # Better to do this after potentially exhausting entries
             ie_result['playlist_count'] = all_entries.get_full_count()
 
-        ie_copy = collections.ChainMap(
-            ie_result, self._playlist_infodict(ie_result, n_entries=int_or_none(n_entries)))
+        extra = self._playlist_infodict(ie_result, n_entries=int_or_none(n_entries))
+        ie_copy = collections.ChainMap(ie_result, extra)
 
         _infojson_written = False
         write_playlist_files = self.params.get('allow_playlist_files', True)
@@ -1785,14 +1786,14 @@ def __process_playlist(self, ie_result, download):
             if not lazy and 'playlist-index' in self.params.get('compat_opts', []):
                 playlist_index = ie_result['requested_entries'][i]
 
-            extra = {
+            entry_copy = collections.ChainMap(entry, {
                 **common_info,
                 'n_entries': int_or_none(n_entries),
                 'playlist_index': playlist_index,
                 'playlist_autonumber': i + 1,
-            }
+            })
 
-            if self._match_entry(collections.ChainMap(entry, extra), incomplete=True) is not None:
+            if self._match_entry(entry_copy, incomplete=True) is not None:
                 continue
 
             self.to_screen('[download] Downloading video %s of %s' % (
@@ -3448,7 +3449,7 @@ def _make_archive_id(self, info_dict):
                     break
             else:
                 return
-        return f'{extractor.lower()} {video_id}'
+        return make_archive_id(extractor, video_id)
 
     def in_download_archive(self, info_dict):
         fn = self.params.get('download_archive')
index c106c0ae7541b1e15dbab60d5686f5c68a803982..4024b6ba1e227bb4b9ae5495550156a4d329f3d5 100644 (file)
@@ -1,4 +1,8 @@
-f'You are using an unsupported version of Python. Only Python versions 3.7 and above are supported by yt-dlp'  # noqa: F541
+try:
+    import contextvars  # noqa: F401
+except Exception:
+    raise Exception(
+        f'You are using an unsupported version of Python. Only Python versions 3.7 and above are supported by yt-dlp')  # noqa: F541
 
 __license__ = 'Public Domain'
 
index 0ae0f4301288bea06017b7da5b26f6894b131e7e..bf3fc8258f07bf957ff9fa50df4b69da86dbbd7e 100644 (file)
@@ -316,7 +316,7 @@ class InfoExtractor:
                     live stream that goes on instead of a fixed-length video.
     was_live:       True, False, or None (=unknown). Whether this video was
                     originally a live stream.
-    live_status:    None (=unknown), 'is_live', 'is_upcoming', 'was_live', 'not_live'
+    live_status:    None (=unknown), 'is_live', 'is_upcoming', 'was_live', 'not_live',
                     or 'post_live' (was live, but VOD is not yet processed)
                     If absent, automatically set from is_live, was_live
     start_time:     Time in seconds where the reproduction should start, as
index 62bd51fd7c4616ef86c15b1da456e243bc07675b..1d3b61c732fbee3f92e772654ebf406520b2522a 100644 (file)
@@ -4,9 +4,7 @@
 
 class CommonMistakesIE(InfoExtractor):
     IE_DESC = False  # Do not list
-    _VALID_URL = r'''(?x)
-        (?:url|URL)$
-    '''
+    _VALID_URL = r'(?:url|URL|yt-dlp)$'
 
     _TESTS = [{
         'url': 'url',
index 5881f1687036f98947ad2d0ac49032e5617e22e9..c70cf50c7e7b822aec19c9d203c5fe8306d7e689 100644 (file)
@@ -5,17 +5,18 @@
 from .common import InfoExtractor
 from ..compat import compat_HTTPError
 from ..utils import (
+    ExtractorError,
     determine_ext,
     int_or_none,
     join_nonempty,
     js_to_json,
+    make_archive_id,
     orderedSet,
     qualities,
     str_or_none,
     traverse_obj,
     try_get,
     urlencode_postdata,
-    ExtractorError,
 )
 
 
@@ -250,7 +251,7 @@ def _real_extract(self, url):
 
         return {
             'id': episode_id,
-            '_old_archive_ids': [initial_experience_id],
+            '_old_archive_ids': [make_archive_id(self, initial_experience_id)],
             'display_id': display_id,
             'duration': duration,
             'title': episode['episodeTitle'],
index f3add479435c21531f8d868b15130d1d88882877..64bd20e3af84457a19ec63800fd88f18e13ccfcc 100644 (file)
@@ -1,4 +1,5 @@
 from .common import InfoExtractor
+from ..utils import make_archive_id
 
 
 class HTML5MediaEmbedIE(InfoExtractor):
@@ -23,7 +24,7 @@ def _extract_from_webpage(self, url, webpage):
                 'id': f'{video_id}-{num}',
                 'title': f'{title} ({num})',
                 '_old_archive_ids': [
-                    f'Generic {f"{video_id}-{num}" if len(entries) > 1 else video_id}',
+                    make_archive_id('generic', f'{video_id}-{num}' if len(entries) > 1 else video_id),
                 ],
             })
             self._sort_formats(entry['formats'])
index 7a798b912d2ac39b6235666ae312999581cd51dd..a667d6ec2de97d7884a0d89d3765119e99cb32c3 100644 (file)
@@ -19,6 +19,7 @@
     dict_get,
     float_or_none,
     int_or_none,
+    make_archive_id,
     parse_duration,
     parse_iso8601,
     parse_qs,
@@ -1166,7 +1167,7 @@ def _real_extract(self, url):
 
         return {
             'id': clip.get('id') or video_id,
-            '_old_archive_ids': [f'{self.ie_key()} {old_id}'] if old_id else None,
+            '_old_archive_ids': [make_archive_id(self, old_id)] if old_id else None,
             'display_id': video_id,
             'title': clip.get('title') or video_id,
             'formats': formats,
index a5c2d10ef510cfcb41785c7b335f5510818c80c5..c0d9c6f79ee1e7c18f44bcfc3e785c134fd5ea79 100644 (file)
@@ -5707,6 +5707,11 @@ def report_retry(e, count, retries, *, sleep_func, info, warn, error=None, suffi
             time.sleep(delay)
 
 
+def make_archive_id(ie, video_id):
+    ie_key = ie if isinstance(ie, str) else ie.ie_key()
+    return f'{ie_key.lower()} {video_id}'
+
+
 # Deprecated
 has_certifi = bool(certifi)
 has_websockets = bool(websockets)