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'https?://(?P<domain>it\.dplay\.com|www\.dplay\.(?:dk|se|no))/[^/]+/(?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',
68 'url': 'http://www.dplay.no/pga-tour/season-1-hoydepunkter-18-21-februar/',
69 'only_matching': True,
72 def _real_extract(self, url):
73 mobj = re.match(self._VALID_URL, url)
74 display_id = mobj.group('id')
75 domain = mobj.group('domain')
77 webpage = self._download_webpage(url, display_id)
79 video_id = self._search_regex(
80 r'data-video-id=["\'](\d+)', webpage, 'video id')
82 info = self._download_json(
83 'http://%s/api/v2/ajax/videos?video_id=%s' % (domain, video_id),
88 PROTOCOLS = ('hls', 'hds')
91 def extract_formats(protocol, manifest_url):
93 formats.extend(self._extract_m3u8_formats(
94 manifest_url, video_id, ext='mp4',
95 entry_protocol='m3u8_native', m3u8_id=protocol, fatal=False))
96 elif protocol == 'hds':
97 formats.extend(self._extract_f4m_formats(
98 manifest_url + '&hdcore=3.8.0&plugin=flowplayer-3.8.0.0',
99 video_id, f4m_id=protocol, fatal=False))
101 domain_tld = domain.split('.')[-1]
102 if domain_tld in ('se', 'dk'):
103 for protocol in PROTOCOLS:
105 'secure.dplay.%s' % domain_tld, 'dsc-geo',
107 'countryCode': domain_tld.upper(),
108 'expiry': (time.time() + 20 * 60) * 1000,
110 stream = self._download_json(
111 'https://secure.dplay.%s/secure/api/v2/user/authorization/stream/%s?stream_type=%s'
112 % (domain_tld, video_id, protocol), video_id,
113 'Downloading %s stream JSON' % protocol, fatal=False)
114 if stream and stream.get(protocol):
115 extract_formats(protocol, stream[protocol])
117 for protocol in PROTOCOLS:
118 if info.get(protocol):
119 extract_formats(protocol, info[protocol])
121 self._sort_formats(formats)
125 'display_id': display_id,
127 'description': info.get('video_metadata_longDescription'),
128 'duration': int_or_none(info.get('video_metadata_length'), scale=1000),
129 'timestamp': int_or_none(info.get('video_publish_date')),
130 'creator': info.get('video_metadata_homeChannel'),
131 'series': info.get('video_metadata_show'),
132 'season_number': int_or_none(info.get('season')),
133 'episode_number': int_or_none(info.get('episode')),
134 'age_limit': int_or_none(info.get('minimum_age')),