]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[egghead:course] Add support for egghead.io course playlists
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 9 Jan 2017 10:24:40 +0000 (11:24 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 9 Jan 2017 10:24:40 +0000 (11:24 +0100)
Individual egghead videos are already handled by the generic/Wistia extractors.

ChangeLog
youtube_dl/extractor/egghead.py [new file with mode: 0644]
youtube_dl/extractor/extractors.py

index da9cf24af409300139cecb6dd2f829efb11d165b..c7cee541272449cc21e87eccabc68d6d197b4b80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+version <unreleased>
+
++ [egghead:course] Add support for egghead.io courses
+
 version 2017.01.08
 
 Core
@@ -14,7 +18,6 @@ Extractors
 * [comedycentral/mtv] Add support for HLS videos (#11600)
 * [discoverygo] Fix JSON data parsing (#11219, #11522)
 
-
 version 2017.01.05
 
 Extractors
diff --git a/youtube_dl/extractor/egghead.py b/youtube_dl/extractor/egghead.py
new file mode 100644 (file)
index 0000000..db92146
--- /dev/null
@@ -0,0 +1,39 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+import re
+
+from .common import InfoExtractor
+
+
+class EggheadCourseIE(InfoExtractor):
+    IE_DESC = 'egghead.io course'
+    IE_NAME = 'egghead:course'
+    _VALID_URL = r'https://egghead\.io/courses/(?P<id>[a-zA-Z_0-9-]+)'
+    _TEST = {
+        'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
+        'playlist_count': 29,
+        'info_dict': {
+            'id': 'professor-frisby-introduces-composable-functional-javascript',
+            'title': 'Professor Frisby Introduces Composable Functional JavaScript',
+            'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
+        },
+    }
+
+    def _real_extract(self, url):
+        playlist_id = self._match_id(url)
+        webpage = self._download_webpage(url, playlist_id)
+
+        title = self._html_search_regex(r'<h1 class="title">([^<]+)</h1>', webpage, 'title')
+        ul = self._search_regex(r'(?s)<ul class="series-lessons-list">(.*?)</ul>', webpage, 'session list')
+
+        found = re.findall(r'(?s)<a class="[^"]*"\s*href="([^"]+)">\s*<li class="item', ul)
+        entries = [self.url_result(m) for m in found]
+
+        return {
+            '_type': 'playlist',
+            'id': playlist_id,
+            'title': title,
+            'description': self._og_search_description(webpage),
+            'entries': entries,
+        }
index f7f6c025fef474a760975a8cc265993b751f4df1..2e80ef1524f4d120a82d8b4f28d5f92bd0f22683 100644 (file)
@@ -252,6 +252,7 @@ from .dw import (
 from .eagleplatform import EaglePlatformIE
 from .ebaumsworld import EbaumsWorldIE
 from .echomsk import EchoMskIE
+from .egghead import EggheadCourseIE
 from .ehow import EHowIE
 from .eighttracks import EightTracksIE
 from .einthusan import EinthusanIE