]>
Commit | Line | Data |
---|---|---|
f063a04f MK |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
f063a04f | 4 | |
4d067a58 | 5 | |
f063a04f | 6 | class DBTVIE(InfoExtractor): |
272355c1 | 7 | _VALID_URL = r'https?://(?:www\.)?dagbladet\.no/video/(?:(?:embed|(?P<display_id>[^/]+))/)?(?P<id>[0-9A-Za-z_-]{11}|[a-zA-Z0-9]{8})' |
7ac40086 | 8 | _TESTS = [{ |
272355c1 RA |
9 | 'url': 'https://www.dagbladet.no/video/PynxJnNWChE/', |
10 | 'md5': 'b8f850ba1860adbda668d367f9b77699', | |
4d067a58 | 11 | 'info_dict': { |
272355c1 | 12 | 'id': 'PynxJnNWChE', |
4d067a58 S |
13 | 'ext': 'mp4', |
14 | 'title': 'Skulle teste ut fornøyelsespark, men kollegaen var bare opptatt av bikinikroppen', | |
272355c1 | 15 | 'description': 'md5:49cc8370e7d66e8a2ef15c3b4631fd3f', |
ec85ded8 | 16 | 'thumbnail': r're:https?://.*\.jpg', |
272355c1 RA |
17 | 'upload_date': '20160916', |
18 | 'duration': 69, | |
19 | 'uploader_id': 'UCk5pvsyZJoYJBd7_oFPTlRQ', | |
20 | 'uploader': 'Dagbladet', | |
8a8590a6 | 21 | }, |
272355c1 | 22 | 'add_ie': ['Youtube'] |
7ac40086 | 23 | }, { |
272355c1 | 24 | 'url': 'https://www.dagbladet.no/video/embed/xlGmyIeN9Jo/?autoplay=false', |
7ac40086 S |
25 | 'only_matching': True, |
26 | }, { | |
272355c1 | 27 | 'url': 'https://www.dagbladet.no/video/truer-iran-bor-passe-dere/PalfB2Cw', |
8a8590a6 | 28 | 'only_matching': True, |
7ac40086 | 29 | }] |
f063a04f | 30 | |
b0c8f2e9 DR |
31 | @staticmethod |
32 | def _extract_urls(webpage): | |
33 | return [url for _, url in re.findall( | |
272355c1 | 34 | r'<iframe[^>]+src=(["\'])((?:https?:)?//(?:www\.)?dagbladet\.no/video/embed/(?:[0-9A-Za-z_-]{11}|[a-zA-Z0-9]{8}).*?)\1', |
b0c8f2e9 DR |
35 | webpage)] |
36 | ||
4d067a58 | 37 | def _real_extract(self, url): |
5ad28e7f | 38 | display_id, video_id = self._match_valid_url(url).groups() |
272355c1 | 39 | info = { |
8a8590a6 | 40 | '_type': 'url_transparent', |
8a8590a6 | 41 | 'id': video_id, |
4d067a58 | 42 | 'display_id': display_id, |
4d067a58 | 43 | } |
272355c1 RA |
44 | if len(video_id) == 11: |
45 | info.update({ | |
46 | 'url': video_id, | |
47 | 'ie_key': 'Youtube', | |
48 | }) | |
49 | else: | |
50 | info.update({ | |
51 | 'url': 'jwplatform:' + video_id, | |
52 | 'ie_key': 'JWPlatform', | |
53 | }) | |
54 | return info |