aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/helsinki.py
blob: 5268efa49433ca8c7cb0c2288df0705165e876a3 (plain)
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
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import re

from .common import InfoExtractor


class HelsinkiIE(InfoExtractor):
    IE_DESC = 'helsinki.fi'
    _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)'
    _TEST = {
        'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258',
        'info_dict': {
            'id': '20258',
            'ext': 'mp4',
            'title': 'Tietotekniikkafoorumi-iltapäivä',
            'description': 'md5:f5c904224d43c133225130fe156a5ee0',
        },
        'params': {
            'skip_download': True,  # RTMP
        }
    }

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        video_id = mobj.group('id')
        webpage = self._download_webpage(url, video_id)
        formats = []

        mobj = re.search(r'file=((\w+):[^&]+)', webpage)
        if mobj:
            formats.append({
                'ext': mobj.group(2),
                'play_path': mobj.group(1),
                'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
                'player_url': 'http://video.helsinki.fi/player.swf',
                'format_note': 'sd',
                'quality': 0,
            })

        mobj = re.search(r'hd\.file=((\w+):[^&]+)', webpage)
        if mobj:
            formats.append({
                'ext': mobj.group(2),
                'play_path': mobj.group(1),
                'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
                'player_url': 'http://video.helsinki.fi/player.swf',
                'format_note': 'hd',
                'quality': 1,
            })

        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': self._og_search_title(webpage).replace('Video: ', ''),
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
            'formats': formats,
        }