about summary refs log tree commit diff
path: root/youtube_dl/extractor/techtalks.py
blob: a55f236cbbca0ac5ef70db2b22eb3c94a778b2c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import re

from .common import InfoExtractor
from ..utils import (
    get_element_by_attribute,
    clean_html,
)


class TechTalksIE(InfoExtractor):
    _VALID_URL = r'https?://techtalks\.tv/talks/[^/]*/(?P<id>\d+)/'

    _TEST = {
        u'url': u'http://techtalks.tv/talks/learning-topic-models-going-beyond-svd/57758/',
        u'playlist': [
            {
                u'file': u'57758.flv',
                u'info_dict': {
                    u'title': u'Learning Topic Models --- Going beyond SVD',
                },
            },
            {
                u'file': u'57758-slides.flv',
                u'info_dict': {
                    u'title': u'Learning Topic Models --- Going beyond SVD',
                },
            },
        ],
        u'params': {
            # rtmp download
            u'skip_download': True,
        },
    }

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        talk_id = mobj.group('id')
        webpage = self._download_webpage(url, talk_id)
        rtmp_url = self._search_regex(r'netConnectionUrl: \'(.*?)\'', webpage,
            u'rtmp url')
        play_path = self._search_regex(r'href=\'(.*?)\' [^>]*id="flowplayer_presenter"',
            webpage, u'presenter play path')
        title = clean_html(get_element_by_attribute('class', 'title', webpage))
        video_info = {
                'id': talk_id,
                'title': title,
                'url': rtmp_url,
                'play_path': play_path,
                'ext': 'flv',
            }
        m_slides = re.search(r'<a class="slides" href=\'(.*?)\'', webpage)
        if m_slides is None:
            return video_info
        else:
            return [
                video_info,
                # The slides video
                {
                    'id': talk_id + '-slides',
                    'title': title,
                    'url': rtmp_url,
                    'play_path': m_slides.group(1),
                    'ext': 'flv',
                },
            ]