[helsinki] Simplify

master
Philipp Hagemeister 10 years ago
parent 4412ca751d
commit 960f317171

@ -8,44 +8,55 @@ from .common import InfoExtractor
class HelsinkiIE(InfoExtractor): class HelsinkiIE(InfoExtractor):
IE_DESC = 'helsinki.fi'
_VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)' _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)'
_TEST = { _TEST = {
'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258', 'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258',
'md5': 'cd829201b890905682eb194cbdea55d7',
'info_dict': { 'info_dict': {
'id': '20258', 'id': '20258',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Tietotekniikkafoorumi-iltapäivä', 'title': 'Tietotekniikkafoorumi-iltapäivä',
'description': 'md5:f5c904224d43c133225130fe156a5ee0',
},
'params': {
'skip_download': True, # RTMP
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
vid = mobj.group('id') video_id = mobj.group('id')
webpage = self._download_webpage(url, vid) webpage = self._download_webpage(url, video_id)
formats = [] formats = []
mobj = re.search('file=((\w+):[^&]+)', webpage)
if mobj: formats.append({ mobj = re.search(r'file=((\w+):[^&]+)', webpage)
'ext': mobj.group(2), if mobj:
'play_path': mobj.group(1), formats.append({
'url': 'rtmp://flashvideo.it.helsinki.fi/vod/', 'ext': mobj.group(2),
'player_url': 'http://video.helsinki.fi/player.swf', 'play_path': mobj.group(1),
'format_note': 'sd' 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
}) 'player_url': 'http://video.helsinki.fi/player.swf',
'format_note': 'sd',
mobj = re.search('hd\.file=((\w+):[^&]+)', webpage) 'quality': 0,
if mobj: formats.append({ })
'ext': mobj.group(2),
'play_path': mobj.group(1), mobj = re.search(r'hd\.file=((\w+):[^&]+)', webpage)
'url': 'rtmp://flashvideo.it.helsinki.fi/vod/', if mobj:
'player_url': 'http://video.helsinki.fi/player.swf', formats.append({
'format_note': 'hd' '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 { return {
'id': vid, 'id': video_id,
'title': self._og_search_title(webpage).replace('Video: ', ''), 'title': self._og_search_title(webpage).replace('Video: ', ''),
'description': self._og_search_description(webpage), 'description': self._og_search_description(webpage),
'thumbnail': self._og_search_thumbnail(webpage), 'thumbnail': self._og_search_thumbnail(webpage),
'formats': formats 'formats': formats,
} }

Loading…
Cancel
Save