]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/infoq.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / infoq.py
index abf7d36ef06304797cf1af92a96da577e4dfc93a..5274c9339fa86d96f48825063edacddae0b46541 100644 (file)
@@ -1,13 +1,13 @@
-from ..compat import (
-    compat_b64decode,
-    compat_urllib_parse_unquote,
-    compat_urlparse,
-)
+import base64
+import urllib.parse
+
+from .bokecc import BokeCCBaseIE
 from ..utils import (
+    ExtractorError,
     determine_ext,
+    traverse_obj,
     update_url_query,
 )
-from .bokecc import BokeCCBaseIE
 
 
 class InfoQIE(BokeCCBaseIE):
@@ -34,6 +34,7 @@ class InfoQIE(BokeCCBaseIE):
             'ext': 'flv',
             'description': 'md5:308d981fb28fa42f49f9568322c683ff',
         },
+        'skip': 'Sorry, the page you visited does not exist',
     }, {
         'url': 'https://www.infoq.com/presentations/Simple-Made-Easy',
         'md5': '0e34642d4d9ef44bf86f66f6399672db',
@@ -56,7 +57,7 @@ def _extract_rtmp_video(self, webpage):
         encoded_id = self._search_regex(
             r"jsclassref\s*=\s*'([^']*)'", webpage, 'encoded id', default=None)
 
-        real_id = compat_urllib_parse_unquote(compat_b64decode(encoded_id).decode('utf-8'))
+        real_id = urllib.parse.unquote(base64.b64decode(encoded_id).decode('utf-8'))
         playpath = 'mp4:' + real_id
 
         return [{
@@ -86,14 +87,16 @@ def _extract_http_video(self, webpage):
         }]
 
     def _extract_http_audio(self, webpage, video_id):
-        fields = self._form_hidden_inputs('mp3Form', webpage)
-        http_audio_url = fields.get('filename')
+        try:
+            http_audio_url = traverse_obj(self._form_hidden_inputs('mp3Form', webpage), 'filename')
+        except ExtractorError:
+            http_audio_url = None
         if not http_audio_url:
             return []
 
         # base URL is found in the Location header in the response returned by
         # GET https://www.infoq.com/mp3download.action?filename=... when logged in.
-        http_audio_url = compat_urlparse.urljoin('http://ress.infoq.com/downloads/mp3downloads/', http_audio_url)
+        http_audio_url = urllib.parse.urljoin('http://ress.infoq.com/downloads/mp3downloads/', http_audio_url)
         http_audio_url = update_url_query(http_audio_url, self._extract_cf_auth(webpage))
 
         # audio file seem to be missing some times even if there is a download link
@@ -123,8 +126,6 @@ def _real_extract(self, url):
                 + self._extract_http_video(webpage)
                 + self._extract_http_audio(webpage, video_id))
 
-        self._sort_formats(formats)
-
         return {
             'id': video_id,
             'title': video_title,