]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/hidive.py
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
20 _NETRC_MACHINE
= 'hidive'
22 _LOGIN_URL
= 'https://www.hidive.com/account/login'
25 'url': 'https://www.hidive.com/stream/the-comic-artist-and-his-assistants/s01e001',
27 'id': 'the-comic-artist-and-his-assistants/s01e001',
29 'title': 'the-comic-artist-and-his-assistants/s01e001',
30 'series': 'the-comic-artist-and-his-assistants',
35 'skip_download': True,
37 'skip': 'Requires Authentication',
40 def _real_initialize(self
):
44 (email
, password
) = self
._get
_login
_info
()
48 webpage
= self
._download
_webpage
(self
._LOGIN
_URL
, None)
49 form
= self
._search
_regex
(
50 r
'(?s)<form[^>]+action="/account/login"[^>]*>(.+?)</form>',
51 webpage
, 'login form')
52 data
= self
._hidden
_inputs
(form
)
57 self
._download
_webpage
(
58 self
._LOGIN
_URL
, None, 'Logging in', data
=urlencode_postdata(data
))
59 self
._LOGGED
_IN
= True
61 def _real_extract(self
, url
):
62 mobj
= re
.match(self
._VALID
_URL
, url
)
63 title
, key
= mobj
.group('title', 'key')
64 video_id
= '%s/%s' % (title
, key
)
66 settings
= self
._download
_json
(
67 'https://www.hidive.com/play/settings', video_id
,
68 data
=urlencode_postdata({
71 'PlayerId': 'f4f895ce1ca713ba263b91caeb1daa2d08904783',
74 restriction
= settings
.get('restrictionReason')
75 if restriction
== 'RegionRestricted':
76 self
.raise_geo_restricted()
78 if restriction
and restriction
!= 'None':
80 '%s said: %s' % (self
.IE_NAME
, restriction
), expected
=True)
84 for rendition_id
, rendition
in settings
['renditions'].items():
85 bitrates
= rendition
.get('bitrates')
86 if not isinstance(bitrates
, dict):
88 m3u8_url
= bitrates
.get('hls')
89 if not isinstance(m3u8_url
, compat_str
):
91 formats
.extend(self
._extract
_m
3u8_formats
(
92 m3u8_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
93 m3u8_id
='%s-hls' % rendition_id
, fatal
=False))
94 cc_files
= rendition
.get('ccFiles')
95 if not isinstance(cc_files
, list):
97 for cc_file
in cc_files
:
98 if not isinstance(cc_file
, list) or len(cc_file
) < 3:
102 if not isinstance(cc_lang
, compat_str
) or not isinstance(
105 subtitles
.setdefault(cc_lang
, []).append({
108 self
._sort
_formats
(formats
)
110 season_number
= int_or_none(self
._search
_regex
(
111 r
's(\d+)', key
, 'season number', default
=None))
112 episode_number
= int_or_none(self
._search
_regex
(
113 r
'e(\d+)', key
, 'episode number', default
=None))
118 'subtitles': subtitles
,
121 'season_number': season_number
,
122 'episode_number': episode_number
,