]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/egghead.py
[cleanup, ie] Match both `http` and `https` in `_VALID_URL` (#8968)
[yt-dlp.git] / yt_dlp / extractor / egghead.py
index aff9b88c0c91e1f1630a673c583dd880dc7adbd5..c94f3f81f66c7daf6259421471fc3c903088d65f 100644 (file)
@@ -1,6 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 from .common import InfoExtractor
 from ..compat import compat_str
 from ..utils import (
@@ -22,16 +19,19 @@ def _call_api(self, path, video_id, resource, fatal=True):
 class EggheadCourseIE(EggheadBaseIE):
     IE_DESC = 'egghead.io course'
     IE_NAME = 'egghead:course'
-    _VALID_URL = r'https://egghead\.io/courses/(?P<id>[^/?#&]+)'
-    _TEST = {
+    _VALID_URL = r'https?://(?:app\.)?egghead\.io/(?:course|playlist)s/(?P<id>[^/?#&]+)'
+    _TESTS = [{
         'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
         'playlist_count': 29,
         'info_dict': {
-            'id': '72',
+            'id': '432655',
             'title': 'Professor Frisby Introduces Composable Functional JavaScript',
             'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
         },
-    }
+    }, {
+        'url': 'https://app.egghead.io/playlists/professor-frisby-introduces-composable-functional-javascript',
+        'only_matching': True,
+    }]
 
     def _real_extract(self, url):
         playlist_id = self._match_id(url)
@@ -65,7 +65,7 @@ def _real_extract(self, url):
 class EggheadLessonIE(EggheadBaseIE):
     IE_DESC = 'egghead.io lesson'
     IE_NAME = 'egghead:lesson'
-    _VALID_URL = r'https://egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
+    _VALID_URL = r'https?://(?:app\.)?egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
     _TESTS = [{
         'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
         'info_dict': {
@@ -83,11 +83,13 @@ class EggheadLessonIE(EggheadBaseIE):
         },
         'params': {
             'skip_download': True,
-            'format': 'bestvideo',
         },
     }, {
         'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application',
         'only_matching': True,
+    }, {
+        'url': 'https://app.egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
+        'only_matching': True,
     }]
 
     def _real_extract(self, url):
@@ -107,8 +109,7 @@ def _real_extract(self, url):
             ext = determine_ext(format_url)
             if ext == 'm3u8':
                 formats.extend(self._extract_m3u8_formats(
-                    format_url, lesson_id, 'mp4', entry_protocol='m3u8',
-                    m3u8_id='hls', fatal=False))
+                    format_url, lesson_id, 'mp4', m3u8_id='hls', fatal=False))
             elif ext == 'mpd':
                 formats.extend(self._extract_mpd_formats(
                     format_url, lesson_id, mpd_id='dash', fatal=False))
@@ -116,7 +117,6 @@ def _real_extract(self, url):
                 formats.append({
                     'url': format_url,
                 })
-        self._sort_formats(formats)
 
         return {
             'id': lesson_id,