2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_str
15 class DBTVIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?dbtv\.no/(?:(?:lazyplayer|player)/)?(?P<id>[0-9]+)(?:#(?P<display_id>.+))?'
18 'url': 'http://dbtv.no/3649835190001#Skulle_teste_ut_fornøyelsespark,_men_kollegaen_var_bare_opptatt_av_bikinikroppen',
19 'md5': 'b89953ed25dacb6edb3ef6c6f430f8bc',
22 'display_id': 'Skulle_teste_ut_fornøyelsespark,_men_kollegaen_var_bare_opptatt_av_bikinikroppen',
24 'title': 'Skulle teste ut fornøyelsespark, men kollegaen var bare opptatt av bikinikroppen',
25 'description': 'md5:1504a54606c4dde3e4e61fc97aa857e0',
26 'thumbnail': 're:https?://.*\.jpg$',
27 'timestamp': 1404039863.438,
28 'upload_date': '20140629',
34 'url': 'http://dbtv.no/3649835190001',
35 'only_matching': True,
37 'url': 'http://www.dbtv.no/lazyplayer/4631135248001',
38 'only_matching': True,
41 def _real_extract(self, url):
42 mobj = re.match(self._VALID_URL, url)
43 video_id = mobj.group('id')
44 display_id = mobj.group('display_id') or video_id
46 data = self._download_json(
47 'http://api.dbtv.no/discovery/%s' % video_id, display_id)
49 video = data['playlist'][0]
53 'vcodec': f.get('container'),
54 'width': int_or_none(f.get('width')),
55 'height': int_or_none(f.get('height')),
56 'vbr': float_or_none(f.get('rate'), 1000),
57 'filesize': int_or_none(f.get('size')),
58 } for f in video['renditions'] if 'URL' in f]
61 for url_key, format_id in [('URL', 'mp4'), ('HLSURL', 'hls')]:
64 'url': video[url_key],
65 'format_id': format_id,
68 self._sort_formats(formats)
71 'id': compat_str(video['id']),
72 'display_id': display_id,
73 'title': video['title'],
74 'description': clean_html(video['desc']),
75 'thumbnail': video.get('splash') or video.get('thumb'),
76 'timestamp': float_or_none(video.get('publishedAt'), 1000),
77 'duration': float_or_none(video.get('length'), 1000),
78 'view_count': int_or_none(video.get('views')),
79 'categories': video.get('tags'),