2 from __future__ import unicode_literals
8 from .adobepass import AdobePass
9 from ..compat import compat_HTTPError
20 class VicelandIE(AdobePass):
21 _VALID_URL = r'https?://(?:www\.)?viceland\.com/[^/]+/video/[^/]+/(?P<id>[a-f0-9]+)'
23 # FIXME: fill the test after fixing delegation problem
24 'url': 'https://www.viceland.com/en_us/video/cyberwar-trailer/57608447973ee7705f6fbd4e',
26 'id': '57608447973ee7705f6fbd4e',
31 'skip_download': True,
33 'add_ie': ['UplynkPreplay', 'Uplynk'],
36 def _real_extract(self, url):
37 video_id = self._match_id(url)
39 webpage = self._download_webpage(url, video_id)
40 watch_hub_data = extract_attributes(self._search_regex(
41 r'(?s)(<watch-hub\s*.+?</watch-hub>)', webpage, 'watch hub'))
42 video_id = watch_hub_data['vms-id']
43 title = watch_hub_data['video-title']
46 if watch_hub_data.get('video-locked') == '1':
47 resource = self._get_mvpd_resource(
48 'VICELAND', title, video_id,
49 watch_hub_data.get('video-rating'))
50 query['tvetoken'] = self._extract_mvpd_auth(url, video_id, 'VICELAND', resource)
52 # signature generation algorithm is reverse engineered from signatureGenerator in
53 # webpack:///../shared/~/vice-player/dist/js/vice-player.js in
54 # https://www.viceland.com/assets/common/js/web.vendor.bundle.js
55 exp = int(time.time()) + 14400
58 'sign': hashlib.sha512(('%s:GET:%d' % (video_id, exp)).encode()).hexdigest(),
62 preplay = self._download_json('https://www.viceland.com/en_us/preplay/%s' % video_id, video_id, query=query)
63 except ExtractorError as e:
64 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
65 error = json.loads(e.cause.read().decode())
66 raise ExtractorError('%s said: %s' % (self.IE_NAME, error['details']), expected=True)
68 video_data = preplay['video']
69 base = video_data['base']
70 uplynk_preplay_url = preplay['preplayURL']
71 episode = video_data.get('episode', {})
72 channel = video_data.get('channel', {})
75 cc_url = preplay.get('ccURL')
82 '_type': 'url_transparent',
83 'url': uplynk_preplay_url,
86 'description': base.get('body'),
87 'thumbnail': watch_hub_data.get('cover-image') or watch_hub_data.get('thumbnail'),
88 'duration': parse_duration(video_data.get('video_duration') or watch_hub_data.get('video-duration')),
89 'timestamp': int_or_none(video_data.get('created_at')),
90 'age_limit': parse_age_limit(video_data.get('video_rating')),
91 'series': video_data.get('show_title') or watch_hub_data.get('show-title'),
92 'episode_number': int_or_none(episode.get('episode_number') or watch_hub_data.get('episode')),
93 'episode_id': str_or_none(episode.get('id') or video_data.get('episode_id')),
94 'season_number': int_or_none(watch_hub_data.get('season')),
95 'season_id': str_or_none(episode.get('season_id')),
96 'uploader': channel.get('base', {}).get('title') or watch_hub_data.get('channel-title'),
97 'uploader_id': str_or_none(channel.get('id')),
98 'subtitles': subtitles,
99 'ie_key': 'UplynkPreplay',