]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/egghead.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / egghead.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class EggheadCourseIE(InfoExtractor):
10 IE_DESC = 'egghead.io course'
11 IE_NAME = 'egghead:course'
12 _VALID_URL = r'https://egghead\.io/courses/(?P<id>[a-zA-Z_0-9-]+)'
13 _TEST = {
14 'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
15 'playlist_count': 29,
16 'info_dict': {
17 'id': 'professor-frisby-introduces-composable-functional-javascript',
18 'title': 'Professor Frisby Introduces Composable Functional JavaScript',
19 'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
20 },
21 }
22
23 def _real_extract(self, url):
24 playlist_id = self._match_id(url)
25 webpage = self._download_webpage(url, playlist_id)
26
27 title = self._html_search_regex(r'<h1 class="title">([^<]+)</h1>', webpage, 'title')
28 ul = self._search_regex(r'(?s)<ul class="series-lessons-list">(.*?)</ul>', webpage, 'session list')
29
30 found = re.findall(r'(?s)<a class="[^"]*"\s*href="([^"]+)">\s*<li class="item', ul)
31 entries = [self.url_result(m) for m in found]
32
33 return {
34 '_type': 'playlist',
35 'id': playlist_id,
36 'title': title,
37 'description': self._og_search_description(webpage),
38 'entries': entries,
39 }