]>
Commit | Line | Data |
---|---|---|
d21ab292 JMF |
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): | |
6eb5503b | 11 | _VALID_URL = r'https?://techtalks\.tv/talks/(?:[^/]+/)?(?P<id>\d+)' |
d21ab292 | 12 | |
6eb5503b | 13 | _TESTS = [{ |
c1a3c9dd S |
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': [ | |
d21ab292 | 20 | { |
c1a3c9dd S |
21 | 'info_dict': { |
22 | 'id': '57758', | |
23 | 'ext': 'flv', | |
24 | 'title': 'Learning Topic Models --- Going beyond SVD', | |
d21ab292 JMF |
25 | }, |
26 | }, | |
27 | { | |
c1a3c9dd S |
28 | 'info_dict': { |
29 | 'id': '57758-slides', | |
30 | 'ext': 'flv', | |
31 | 'title': 'Learning Topic Models --- Going beyond SVD', | |
d21ab292 JMF |
32 | }, |
33 | }, | |
34 | ], | |
c1a3c9dd | 35 | 'params': { |
d21ab292 | 36 | # rtmp download |
c1a3c9dd | 37 | 'skip_download': True, |
d21ab292 | 38 | }, |
6eb5503b S |
39 | }, { |
40 | 'url': 'http://techtalks.tv/talks/57758', | |
41 | 'only_matching': True, | |
42 | }] | |
d21ab292 JMF |
43 | |
44 | def _real_extract(self, url): | |
5ad28e7f | 45 | mobj = self._match_valid_url(url) |
d21ab292 JMF |
46 | talk_id = mobj.group('id') |
47 | webpage = self._download_webpage(url, talk_id) | |
c1a3c9dd S |
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') | |
d21ab292 JMF |
53 | title = clean_html(get_element_by_attribute('class', 'title', webpage)) |
54 | video_info = { | |
c1a3c9dd S |
55 | 'id': talk_id, |
56 | 'title': title, | |
57 | 'url': rtmp_url, | |
58 | 'play_path': play_path, | |
59 | 'ext': 'flv', | |
60 | } | |
d21ab292 JMF |
61 | m_slides = re.search(r'<a class="slides" href=\'(.*?)\'', webpage) |
62 | if m_slides is None: | |
63 | return video_info | |
64 | else: | |
c1a3c9dd S |
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 | } |