- assert '"fsk"' in html
- raise ExtractorError(u'This video is only available after 8:00 pm')
-
- # choose default media type and highest quality for now
- stream = max([s for s in streams if int(s["media_type"]) == 0],
- key=lambda s: int(s["quality"]))
-
- # there's two possibilities: RTMP stream or HTTP download
- info = {'id': video_id, 'title': title, 'ext': 'mp4'}
- if stream['rtmp_url']:
- self.to_screen(u'RTMP download detected')
- assert stream['video_url'].startswith('mp4:')
- info["url"] = stream["rtmp_url"]
- info["play_path"] = stream['video_url']
- else:
- assert stream["video_url"].endswith('.mp4')
- info["url"] = stream["video_url"]
- return [info]
+ if '"fsk"' in webpage:
+ raise ExtractorError('This video is only available after 20:00')
+
+ formats = []
+ for s in streams:
+ format = {
+ 'quality': int(s['quality']),
+ }
+ if s.get('rtmp_url'):
+ format['protocol'] = 'rtmp'
+ format['url'] = s['rtmp_url']
+ format['playpath'] = s['video_url']
+ else:
+ format['url'] = s['video_url']
+
+ quality_name = self._search_regex(
+ r'[,.]([a-zA-Z0-9_-]+),?\.mp4', format['url'],
+ 'quality name', default='NA')
+ format['format_id'] = '%s-%s-%s-%s' % (
+ determine_ext(format['url']), quality_name, s['media_type'],
+ s['quality'])
+
+ formats.append(format)
+
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'description': description,
+ 'formats': formats,
+ 'thumbnail': thumbnail,
+ }