2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class KanalPlayIE(InfoExtractor):
14 IE_DESC = 'Kanal 5/9/11 Play'
15 _VALID_URL = r'https?://(?:www\.)?kanal(?P<channel_id>5|9|11)play\.se/(?:#!/)?(?:play/)?program/\d+/video/(?P<id>\d+)'
17 'url': 'http://www.kanal5play.se/#!/play/program/3060212363/video/3270012277',
22 'title': 'Saknar både dusch och avlopp',
23 'description': 'md5:',
27 'url': 'http://www.kanal9play.se/#!/play/program/335032/video/246042',
28 'only_matching': True,
30 'url': 'http://www.kanal11play.se/#!/play/program/232835958/video/367135199',
31 'only_matching': True,
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
36 video_id = mobj.group('id')
37 channel_id = mobj.group('channel_id')
39 video = self._download_json(
40 'http://www.kanal%splay.se/api/getVideo?format=FLASH&videoId=%s' % (channel_id, video_id),
43 reasons_for_no_streams = video.get('reasonsForNoStreams')
44 if reasons_for_no_streams:
46 '%s returned error: %s' % (self.IE_NAME, '\n'.join(reasons_for_no_streams)),
49 title = video['title']
50 description = video.get('description')
51 duration = float_or_none(video.get('length'), 1000)
52 thumbnail = video.get('posterUrl')
54 stream_base_url = video['streamBaseUrl']
57 'url': stream_base_url,
58 'play_path': stream['source'],
60 'tbr': float_or_none(stream.get('bitrate'), 1000),
61 'rtmp_real_time': True,
62 } for stream in video['streams']]
63 self._sort_formats(formats)
68 'description': description,
69 'thumbnail': thumbnail,