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