]>
Commit | Line | Data |
---|---|---|
8e7a9016 JJ |
1 | from __future__ import unicode_literals |
2 | ||
8e7a9016 | 3 | |
8e2ec955 PH |
4 | from .common import InfoExtractor |
5 | from ..utils import ( | |
87b5184a S |
6 | js_to_json, |
7 | parse_duration, | |
8 | unescapeHTML, | |
8e2ec955 PH |
9 | ) |
10 | ||
11 | ||
8e7a9016 | 12 | class DRBonanzaIE(InfoExtractor): |
87b5184a S |
13 | _VALID_URL = r'https?://(?:www\.)?dr\.dk/bonanza/[^/]+/\d+/[^/]+/(?P<id>\d+)/(?P<display_id>[^/?#&]+)' |
14 | _TEST = { | |
15 | 'url': 'http://www.dr.dk/bonanza/serie/154/matador/40312/matador---0824-komme-fremmede-', | |
8e7a9016 | 16 | 'info_dict': { |
87b5184a S |
17 | 'id': '40312', |
18 | 'display_id': 'matador---0824-komme-fremmede-', | |
8e7a9016 | 19 | 'ext': 'mp4', |
87b5184a S |
20 | 'title': 'MATADOR - 08:24. "Komme fremmede".', |
21 | 'description': 'md5:77b4c1ac4d4c1b9d610ab4395212ff84', | |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$', |
87b5184a | 23 | 'duration': 4613, |
8e7a9016 | 24 | }, |
87b5184a | 25 | } |
8e7a9016 JJ |
26 | |
27 | def _real_extract(self, url): | |
5ad28e7f | 28 | mobj = self._match_valid_url(url) |
87b5184a | 29 | video_id, display_id = mobj.group('id', 'display_id') |
8e2ec955 | 30 | |
87b5184a | 31 | webpage = self._download_webpage(url, display_id) |
8e2ec955 | 32 | |
87b5184a S |
33 | info = self._parse_html5_media_entries( |
34 | url, webpage, display_id, m3u8_id='hls', | |
35 | m3u8_entry_protocol='m3u8_native')[0] | |
36 | self._sort_formats(info['formats']) | |
8e2ec955 | 37 | |
87b5184a S |
38 | asset = self._parse_json( |
39 | self._search_regex( | |
40 | r'(?s)currentAsset\s*=\s*({.+?})\s*</script', webpage, 'asset'), | |
41 | display_id, transform_source=js_to_json) | |
8e7a9016 | 42 | |
87b5184a | 43 | title = unescapeHTML(asset['AssetTitle']).strip() |
8e2ec955 | 44 | |
87b5184a S |
45 | def extract(field): |
46 | return self._search_regex( | |
47 | r'<div[^>]+>\s*<p>%s:<p>\s*</div>\s*<div[^>]+>\s*<p>([^<]+)</p>' % field, | |
48 | webpage, field, default=None) | |
8e2ec955 | 49 | |
87b5184a S |
50 | info.update({ |
51 | 'id': asset.get('AssetId') or video_id, | |
8e7a9016 JJ |
52 | 'display_id': display_id, |
53 | 'title': title, | |
87b5184a S |
54 | 'description': extract('Programinfo'), |
55 | 'duration': parse_duration(extract('Tid')), | |
56 | 'thumbnail': asset.get('AssetImageUrl'), | |
57 | }) | |
58 | return info |