]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/udemy.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / udemy.py
index d35cd0d4310fa3620f084db37008f8e2f73023ec..8b99c59cf546430d06073002ea9cd4da822823ee 100644 (file)
@@ -1,16 +1,12 @@
 import re
+import urllib.request
 
 from .common import InfoExtractor
-from ..compat import (
-    compat_HTTPError,
-    compat_str,
-    compat_urllib_request,
-    compat_urlparse,
-)
+from ..compat import compat_HTTPError, compat_str, compat_urlparse
 from ..utils import (
+    ExtractorError,
     determine_ext,
     extract_attributes,
-    ExtractorError,
     float_or_none,
     int_or_none,
     js_to_json,
@@ -148,14 +144,14 @@ def _download_json(self, url_or_request, *args, **kwargs):
             'X-Udemy-Snail-Case': 'true',
             'X-Requested-With': 'XMLHttpRequest',
         }
-        for cookie in self._downloader.cookiejar:
+        for cookie in self.cookiejar:
             if cookie.name == 'client_id':
                 headers['X-Udemy-Client-Id'] = cookie.value
             elif cookie.name == 'access_token':
                 headers['X-Udemy-Bearer-Token'] = cookie.value
                 headers['X-Udemy-Authorization'] = 'Bearer %s' % cookie.value
 
-        if isinstance(url_or_request, compat_urllib_request.Request):
+        if isinstance(url_or_request, urllib.request.Request):
             for header, value in headers.items():
                 url_or_request.add_header(header, value)
         else:
@@ -395,8 +391,6 @@ def extract_subtitles(track_list):
                 if f.get('url'):
                     formats.append(f)
 
-        self._sort_formats(formats)
-
         return {
             'id': video_id,
             'title': title,
@@ -409,7 +403,7 @@ def extract_subtitles(track_list):
         }
 
 
-class UdemyCourseIE(UdemyIE):
+class UdemyCourseIE(UdemyIE):  # XXX: Do not subclass from concrete IE
     IE_NAME = 'udemy:course'
     _VALID_URL = r'https?://(?:[^/]+\.)?udemy\.com/(?P<id>[^/?#&]+)'
     _TESTS = [{