]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/techtalks.py
d37de360b8d7405dd81781fcaa1c6727cdc1462c
[yt-dlp.git] / yt_dlp / extractor / techtalks.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 get_element_by_attribute,
6 clean_html,
7 )
8
9
10 class TechTalksIE(InfoExtractor):
11 _VALID_URL = r'https?://techtalks\.tv/talks/(?:[^/]+/)?(?P<id>\d+)'
12
13 _TESTS = [{
14 'url': 'http://techtalks.tv/talks/learning-topic-models-going-beyond-svd/57758/',
15 'info_dict': {
16 'id': '57758',
17 'title': 'Learning Topic Models --- Going beyond SVD',
18 },
19 'playlist': [
20 {
21 'info_dict': {
22 'id': '57758',
23 'ext': 'flv',
24 'title': 'Learning Topic Models --- Going beyond SVD',
25 },
26 },
27 {
28 'info_dict': {
29 'id': '57758-slides',
30 'ext': 'flv',
31 'title': 'Learning Topic Models --- Going beyond SVD',
32 },
33 },
34 ],
35 'params': {
36 # rtmp download
37 'skip_download': True,
38 },
39 }, {
40 'url': 'http://techtalks.tv/talks/57758',
41 'only_matching': True,
42 }]
43
44 def _real_extract(self, url):
45 mobj = self._match_valid_url(url)
46 talk_id = mobj.group('id')
47 webpage = self._download_webpage(url, talk_id)
48 rtmp_url = self._search_regex(
49 r'netConnectionUrl: \'(.*?)\'', webpage, 'rtmp url')
50 play_path = self._search_regex(
51 r'href=\'(.*?)\' [^>]*id="flowplayer_presenter"',
52 webpage, 'presenter play path')
53 title = clean_html(get_element_by_attribute('class', 'title', webpage))
54 video_info = {
55 'id': talk_id,
56 'title': title,
57 'url': rtmp_url,
58 'play_path': play_path,
59 'ext': 'flv',
60 }
61 m_slides = re.search(r'<a class="slides" href=\'(.*?)\'', webpage)
62 if m_slides is None:
63 return video_info
64 else:
65 return {
66 '_type': 'playlist',
67 'id': talk_id,
68 'title': title,
69 'entries': [
70 video_info,
71 # The slides video
72 {
73 'id': talk_id + '-slides',
74 'title': title,
75 'url': rtmp_url,
76 'play_path': m_slides.group(1),
77 'ext': 'flv',
78 },
79 ],
80 }