2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_str
15 class HiDiveIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?hidive\.com/stream/(?P<title>[^/]+)/(?P<key>[^/?#&]+)'
17 # Using X-Forwarded-For results in 403 HTTP error for HLS fragments,
18 # so disabling geo bypass completely
22 'url': 'https://www.hidive.com/stream/the-comic-artist-and-his-assistants/s01e001',
24 'id': 'the-comic-artist-and-his-assistants/s01e001',
26 'title': 'the-comic-artist-and-his-assistants/s01e001',
27 'series': 'the-comic-artist-and-his-assistants',
32 'skip_download': True,
36 def _real_extract(self, url):
37 mobj = re.match(self._VALID_URL, url)
38 title, key = mobj.group('title', 'key')
39 video_id = '%s/%s' % (title, key)
41 settings = self._download_json(
42 'https://www.hidive.com/play/settings', video_id,
43 data=urlencode_postdata({
48 restriction = settings.get('restrictionReason')
49 if restriction == 'RegionRestricted':
50 self.raise_geo_restricted()
52 if restriction and restriction != 'None':
54 '%s said: %s' % (self.IE_NAME, restriction), expected=True)
58 for rendition_id, rendition in settings['renditions'].items():
59 bitrates = rendition.get('bitrates')
60 if not isinstance(bitrates, dict):
62 m3u8_url = bitrates.get('hls')
63 if not isinstance(m3u8_url, compat_str):
65 formats.extend(self._extract_m3u8_formats(
66 m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
67 m3u8_id='%s-hls' % rendition_id, fatal=False))
68 cc_files = rendition.get('ccFiles')
69 if not isinstance(cc_files, list):
71 for cc_file in cc_files:
72 if not isinstance(cc_file, list) or len(cc_file) < 3:
76 if not isinstance(cc_lang, compat_str) or not isinstance(
79 subtitles.setdefault(cc_lang, []).append({
83 season_number = int_or_none(self._search_regex(
84 r's(\d+)', key, 'season number', default=None))
85 episode_number = int_or_none(self._search_regex(
86 r'e(\d+)', key, 'episode number', default=None))
91 'subtitles': subtitles,
94 'season_number': season_number,
95 'episode_number': episode_number,