]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/alura.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / alura.py
index ae7115f9f1a54a5bbfd51bc4c4c01e07fe056704..ce03a4265bec356e04d5f488cc0e9d504344f406 100644 (file)
@@ -1,17 +1,13 @@
 import re
+import urllib.parse
 
 from .common import InfoExtractor
-
-from ..compat import (
-    compat_urlparse,
-)
-
 from ..utils import (
+    ExtractorError,
+    clean_html,
+    int_or_none,
     urlencode_postdata,
     urljoin,
-    int_or_none,
-    clean_html,
-    ExtractorError
 )
 
 
@@ -25,7 +21,7 @@ class AluraIE(InfoExtractor):
         'info_dict': {
             'id': '60095',
             'ext': 'mp4',
-            'title': 'ReferĂȘncias, ref-set e alter'
+            'title': 'ReferĂȘncias, ref-set e alter',
         },
         'skip': 'Requires alura account credentials'},
         {
@@ -34,12 +30,12 @@ class AluraIE(InfoExtractor):
             'only_matching': True},
         {
             'url': 'https://cursos.alura.com.br/course/fundamentos-market-digital/task/55219',
-            'only_matching': True}
+            'only_matching': True},
     ]
 
     def _real_extract(self, url):
 
-        course, video_id = self._match_valid_url(url)
+        course, video_id = self._match_valid_url(url).group('course_name', 'id')
         video_url = self._VIDEO_URL % (course, video_id)
 
         video_dict = self._download_json(video_url, video_id, 'Searching for videos')
@@ -52,7 +48,7 @@ def _real_extract(self, url):
 
             formats = []
             for video_obj in video_dict:
-                video_url_m3u8 = video_obj.get('link')
+                video_url_m3u8 = video_obj.get('mp4')
                 video_format = self._extract_m3u8_formats(
                     video_url_m3u8, None, 'mp4', entry_protocol='m3u8_native',
                     m3u8_id='hls', fatal=False)
@@ -63,12 +59,10 @@ def _real_extract(self, url):
                             f['height'] = int('720' if m.group('res') == 'hd' else '480')
                 formats.extend(video_format)
 
-            self._sort_formats(formats)
-
             return {
                 'id': video_id,
                 'title': video_title,
-                "formats": formats
+                'formats': formats,
             }
 
     def _perform_login(self, username, password):
@@ -97,7 +91,7 @@ def is_logged(webpage):
             'post url', default=self._LOGIN_URL, group='url')
 
         if not post_url.startswith('http'):
-            post_url = compat_urlparse.urljoin(self._LOGIN_URL, post_url)
+            post_url = urllib.parse.urljoin(self._LOGIN_URL, post_url)
 
         response = self._download_webpage(
             post_url, None, 'Logging in',
@@ -109,7 +103,7 @@ def is_logged(webpage):
                 r'(?s)<p[^>]+class="alert-message[^"]*">(.+?)</p>',
                 response, 'error message', default=None)
             if error:
-                raise ExtractorError('Unable to login: %s' % error, expected=True)
+                raise ExtractorError(f'Unable to login: {error}', expected=True)
             raise ExtractorError('Unable to log in')
 
 
@@ -125,7 +119,7 @@ class AluraCourseIE(AluraIE):  # XXX: Do not subclass from concrete IE
 
     @classmethod
     def suitable(cls, url):
-        return False if AluraIE.suitable(url) else super(AluraCourseIE, cls).suitable(url)
+        return False if AluraIE.suitable(url) else super().suitable(url)
 
     def _real_extract(self, url):
 
@@ -163,7 +157,7 @@ def _real_extract(self, url):
                         'url': video_url,
                         'id_key': self.ie_key(),
                         'chapter': chapter,
-                        'chapter_number': chapter_number
+                        'chapter_number': chapter_number,
                     }
                     entries.append(entry)
         return self.playlist_result(entries, course_path, course_title)