2 from __future__
import unicode_literals
8 from .common
import InfoExtractor
9 from ..utils
import int_or_none
12 class DPlayIE(InfoExtractor
):
13 _VALID_URL
= r
'http://(?P<domain>it\.dplay\.com|www\.dplay\.(?:dk|se))/[^/]+/(?P<id>[^/?#]+)'
16 'url': 'http://it.dplay.com/take-me-out/stagione-1-episodio-25/',
19 'display_id': 'stagione-1-episodio-25',
21 'title': 'Episodio 25',
22 'description': 'md5:cae5f40ad988811b197d2d27a53227eb',
24 'timestamp': 1454701800,
25 'upload_date': '20160205',
27 'series': 'Take me out',
32 'expected_warnings': ['Unable to download f4m manifest'],
34 'url': 'http://www.dplay.se/nugammalt-77-handelser-som-format-sverige/season-1-svensken-lar-sig-njuta-av-livet/',
37 'display_id': 'season-1-svensken-lar-sig-njuta-av-livet',
39 'title': 'Svensken lär sig njuta av livet',
40 'description': 'md5:d3819c9bccffd0fe458ca42451dd50d8',
42 'timestamp': 1365454320,
43 'upload_date': '20130408',
44 'creator': 'Kanal 5 (Home)',
45 'series': 'Nugammalt - 77 händelser som format Sverige',
51 'url': 'http://www.dplay.dk/mig-og-min-mor/season-6-episode-12/',
54 'display_id': 'season-6-episode-12',
56 'title': 'Episode 12',
57 'description': 'md5:9c86e51a93f8a4401fc9641ef9894c90',
59 'timestamp': 1429696800,
60 'upload_date': '20150422',
62 'series': 'Mig og min mor',
69 def _real_extract(self
, url
):
70 mobj
= re
.match(self
._VALID
_URL
, url
)
71 display_id
= mobj
.group('id')
72 domain
= mobj
.group('domain')
74 webpage
= self
._download
_webpage
(url
, display_id
)
76 video_id
= self
._search
_regex
(
77 r
'data-video-id=["\'](\d
+)', webpage, 'video
id')
79 info = self._download_json(
80 'http
://%s/api
/v2
/ajax
/videos?video_id
=%s' % (domain, video_id),
85 PROTOCOLS = ('hls
', 'hds
')
88 def extract_formats(protocol, manifest_url):
90 formats.extend(self._extract_m3u8_formats(
91 manifest_url, video_id, ext='mp4
',
92 entry_protocol='m3u8_native
', m3u8_id=protocol, fatal=False))
93 elif protocol == 'hds
':
94 formats.extend(self._extract_f4m_formats(
95 manifest_url + '&hdcore
=3.8.0&plugin
=flowplayer
-3.8.0.0',
96 video_id, f4m_id=protocol, fatal=False))
98 domain_tld = domain.split('.')[-1]
99 if domain_tld in ('se
', 'dk
'):
100 for protocol in PROTOCOLS:
102 'secure
.dplay
.%s' % domain_tld, 'dsc
-geo
',
104 'countryCode
': domain_tld.upper(),
105 'expiry
': (time.time() + 20 * 60) * 1000,
107 stream = self._download_json(
108 'https
://secure
.dplay
.%s/secure
/api
/v2
/user
/authorization
/stream
/%s?stream_type
=%s'
109 % (domain_tld, video_id, protocol), video_id,
110 'Downloading
%s stream JSON
' % protocol, fatal=False)
111 if stream and stream.get(protocol):
112 extract_formats(protocol, stream[protocol])
114 for protocol in PROTOCOLS:
115 if info.get(protocol):
116 extract_formats(protocol, info[protocol])
120 'display_id
': display_id,
122 'description
': info.get('video_metadata_longDescription
'),
123 'duration
': int_or_none(info.get('video_metadata_length
'), scale=1000),
124 'timestamp
': int_or_none(info.get('video_publish_date
')),
125 'creator
': info.get('video_metadata_homeChannel
'),
126 'series
': info.get('video_metadata_show
'),
127 'season_number
': int_or_none(info.get('season
')),
128 'episode_number
': int_or_none(info.get('episode
')),
129 'age_limit
': int_or_none(info.get('minimum_age
')),