- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group('id')
- display_id = mobj.group('display_id') or video_id
-
- data = self._download_json(
- 'http://api.dbtv.no/discovery/%s' % video_id, display_id)
-
- video = data['playlist'][0]
-
- formats = [{
- 'url': f['URL'],
- 'vcodec': f.get('container'),
- 'width': int_or_none(f.get('width')),
- 'height': int_or_none(f.get('height')),
- 'vbr': float_or_none(f.get('rate'), 1000),
- 'filesize': int_or_none(f.get('size')),
- } for f in video['renditions'] if 'URL' in f]
-
- if not formats:
- for url_key, format_id in [('URL', 'mp4'), ('HLSURL', 'hls')]:
- if url_key in video:
- formats.append({
- 'url': video[url_key],
- 'format_id': format_id,
- })
-
- self._sort_formats(formats)