]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/downloader/fragment.py
[compat] Remove more functions
[yt-dlp.git] / yt_dlp / downloader / fragment.py
index 79161b8092d32f8e09adef2c1396ecd2a5f63e50..3535e0e7d1bdc1ecde78c48b861a2f8d8d57a327 100644 (file)
@@ -4,12 +4,14 @@
 import json
 import math
 import os
+import struct
 import time
+import urllib.error
 
 from .common import FileDownloader
 from .http import HttpFD
 from ..aes import aes_cbc_decrypt_bytes, unpad_pkcs7
-from ..compat import compat_os_name, compat_struct_pack, compat_urllib_error
+from ..compat import compat_os_name
 from ..utils import (
     DownloadError,
     encodeFilename,
@@ -23,7 +25,7 @@ class HttpQuietDownloader(HttpFD):
     def to_screen(self, *args, **kargs):
         pass
 
-    console_title = to_screen
+    to_console_title = to_screen
 
 
 class FragmentFD(FileDownloader):
@@ -348,7 +350,7 @@ def decrypt_fragment(fragment, frag_content):
             decrypt_info = fragment.get('decrypt_info')
             if not decrypt_info or decrypt_info['METHOD'] != 'AES-128':
                 return frag_content
-            iv = decrypt_info.get('IV') or compat_struct_pack('>8xq', fragment['media_sequence'])
+            iv = decrypt_info.get('IV') or struct.pack('>8xq', fragment['media_sequence'])
             decrypt_info['KEY'] = decrypt_info.get('KEY') or _get_key(info_dict.get('_decryption_key_url') or decrypt_info['URI'])
             # Don't decrypt the content in tests since the data is explicitly truncated and it's not to a valid block
             # size (see https://github.com/ytdl-org/youtube-dl/pull/27660). Tests only care that the correct data downloaded,
@@ -457,7 +459,7 @@ def download_fragment(fragment, ctx):
                     if self._download_fragment(ctx, fragment['url'], info_dict, headers):
                         break
                     return
-                except (compat_urllib_error.HTTPError, http.client.IncompleteRead) as err:
+                except (urllib.error.HTTPError, http.client.IncompleteRead) as err:
                     # Unavailable (possibly temporary) fragments may be served.
                     # First we try to retry then either skip or abort.
                     # See https://github.com/ytdl-org/youtube-dl/issues/10165,