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