2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import int_or_none
10 class DPlayIE(InfoExtractor):
11 _VALID_URL = r'http://www\.dplay\.se/[^/]+/(?P<id>[^/?#]+)'
14 'url': 'http://www.dplay.se/nugammalt-77-handelser-som-format-sverige/season-1-svensken-lar-sig-njuta-av-livet/',
18 'display_id': 'season-1-svensken-lar-sig-njuta-av-livet',
19 'title': 'Svensken lär sig njuta av livet',
24 def _real_extract(self, url):
25 display_id = self._match_id(url)
26 webpage = self._download_webpage(url, display_id)
27 video_id = self._search_regex(
28 r'data-video-id="(\d+)"', webpage, 'video id')
30 info = self._download_json(
31 'http://www.dplay.se/api/v2/ajax/videos?video_id=' + video_id,
35 'secure.dplay.se', 'dsc-geo',
36 '{"countryCode":"NL","expiry":%d}' % ((time.time() + 20 * 60) * 1000))
37 # TODO: consider adding support for 'stream_type=hds', it seems to
38 # require setting some cookies
39 manifest_url = self._download_json(
40 'https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hls' % video_id,
41 video_id, 'Getting manifest url for hls stream')['hls']
42 formats = self._extract_m3u8_formats(
43 manifest_url, video_id, ext='mp4', entry_protocol='m3u8_native')
47 'display_id': display_id,
48 'title': info['title'],
50 'duration': int_or_none(info.get('video_metadata_length'), scale=1000),