]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/helsinki.py
[helsinki] Simplify
[yt-dlp.git] / youtube_dl / extractor / helsinki.py
CommitLineData
66c43a53
NL
1# -*- coding: utf-8 -*-
2
3from __future__ import unicode_literals
4
5import re
6
7from .common import InfoExtractor
8
9
10class HelsinkiIE(InfoExtractor):
960f3171 11 IE_DESC = 'helsinki.fi'
66c43a53
NL
12 _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)'
13 _TEST = {
14 'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258',
66c43a53
NL
15 'info_dict': {
16 'id': '20258',
17 'ext': 'mp4',
18 'title': 'Tietotekniikkafoorumi-iltapäivä',
960f3171
PH
19 'description': 'md5:f5c904224d43c133225130fe156a5ee0',
20 },
21 'params': {
22 'skip_download': True, # RTMP
66c43a53
NL
23 }
24 }
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
960f3171
PH
28 video_id = mobj.group('id')
29 webpage = self._download_webpage(url, video_id)
66c43a53 30 formats = []
960f3171
PH
31
32 mobj = re.search(r'file=((\w+):[^&]+)', webpage)
33 if mobj:
34 formats.append({
35 'ext': mobj.group(2),
36 'play_path': mobj.group(1),
37 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
38 'player_url': 'http://video.helsinki.fi/player.swf',
39 'format_note': 'sd',
40 'quality': 0,
41 })
42
43 mobj = re.search(r'hd\.file=((\w+):[^&]+)', webpage)
44 if mobj:
45 formats.append({
46 'ext': mobj.group(2),
47 'play_path': mobj.group(1),
48 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
49 'player_url': 'http://video.helsinki.fi/player.swf',
50 'format_note': 'hd',
51 'quality': 1,
52 })
53
54 self._sort_formats(formats)
66c43a53
NL
55
56 return {
960f3171 57 'id': video_id,
66c43a53
NL
58 'title': self._og_search_title(webpage).replace('Video: ', ''),
59 'description': self._og_search_description(webpage),
60 'thumbnail': self._og_search_thumbnail(webpage),
960f3171 61 'formats': formats,
66c43a53 62 }