]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/go.py
2 from __future__
import unicode_literals
6 from .adobepass
import AdobePassIE
16 class GoIE(AdobePassIE
):
20 'requestor_id': 'ABC',
24 'requestor_id': 'ABCFamily',
26 'watchdisneychannel': {
28 'resource_id': 'Disney',
30 'watchdisneyjunior': {
32 'resource_id': 'DisneyJunior',
36 'resource_id': 'DisneyXD',
40 'resource_id': 'Disney',
44 'requestor_id': 'dtci',
50 (?:(?P<sub_domain>%s)\.)?go|
51 (?P<sub_domain_2>abc|freeform|disneynow|fxnow\.fxnetworks)
54 (?:[^/]+/)*(?P<id>[Vv][Dd][Kk][Aa]\w+)|
55 (?:[^/]+/)*(?P<display_id>[^/?\#]+)
57 ''' % '|'.join(list(_SITE_INFO
.keys()))
59 'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
63 'title': 'The Traitor in the White House',
64 'description': 'md5:05b009d2d145a1e85d25111bd37222e8',
68 'skip_download': True,
70 'skip': 'This content is no longer available.',
72 'url': 'http://watchdisneyxd.go.com/doraemon',
77 'playlist_mincount': 51,
79 'url': 'http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood',
83 'title': 'This Guilty Blood',
84 'description': 'md5:f18e79ad1c613798d95fdabfe96cd292',
88 'geo_bypass_ip_block': '3.244.239.0/24',
90 'skip_download': True,
93 'url': 'https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet',
98 'description': 'md5:c66de8ba2e92c6c5c113c3ade84ab404',
102 'geo_bypass_ip_block': '3.244.239.0/24',
104 'skip_download': True,
107 'url': 'https://fxnow.fxnetworks.com/shows/better-things/video/vdka12782841',
109 'id': 'VDKA12782841',
111 'title': 'First Look: Better Things - Season 2',
112 'description': 'md5:fa73584a95761c605d9d54904e35b407',
115 'geo_bypass_ip_block': '3.244.239.0/24',
117 'skip_download': True,
120 'url': 'http://abc.go.com/shows/the-catch/episode-guide/season-01/10-the-wedding',
121 'only_matching': True,
123 'url': 'http://abc.go.com/shows/world-news-tonight/episode-guide/2017-02/17-021717-intense-stand-off-between-man-with-rifle-and-police-in-oakland',
124 'only_matching': True,
127 'url': 'http://disneynow.go.com/shows/big-hero-6-the-series/season-01/episode-10-mr-sparkles-loses-his-sparkle/vdka4637915',
128 'only_matching': True,
131 'url': 'http://disneynow.go.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
132 'only_matching': True,
134 'url': 'https://disneynow.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
135 'only_matching': True,
138 def _extract_videos(self
, brand
, video_id
='-1', show_id
='-1'):
139 display_id
= video_id
if video_id
!= '-1' else show_id
140 return self
._download
_json
(
141 'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/%s/001/-1/%s/-1/%s/-1/-1.json' % (brand
, show_id
, video_id
),
144 def _real_extract(self
, url
):
145 mobj
= re
.match(self
._VALID
_URL
, url
)
146 sub_domain
= mobj
.group('sub_domain') or mobj
.group('sub_domain_2')
147 video_id
, display_id
= mobj
.group('id', 'display_id')
148 site_info
= self
._SITE
_INFO
.get(sub_domain
, {})
149 brand
= site_info
.get('brand')
150 if not video_id
or not site_info
:
151 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
152 video_id
= self
._search
_regex
(
154 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
155 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
156 r
'data-video-id=["\']*(VDKA\w
+)',
157 # https://github.com/ytdl-org/youtube-dl/pull/25216/files
158 # The following is based on the pull request on the line above. Changed the ABC.com URL to a show available now.
159 # https://abc.com/shows/the-rookie/episode-guide/season-02/19-the-q-word
160 r'\bvideoIdCode
["\']\s*:\s*["\'](vdka\w
+)',
161 # Deprecated fallback pattern
162 r'\b(?
:video
)?
id["\']\s*:\s*["\'](VDKA\w
+)'
163 ), webpage, 'video
id', default=video_id)
165 brand = self._search_regex(
166 (r'data
-brand
=\s
*["\']\s*(\d+)',
167 r'data-page-brand=\s*["\']\s
*(\d
+)'), webpage, 'brand
',
170 si for _, si in self._SITE_INFO.items()
171 if si.get('brand
') == brand)
173 # show extraction works for Disney, DisneyJunior and DisneyXD
174 # ABC and Freeform has different layout
175 show_id = self._search_regex(r'data
-show
-id=["\']*(SH\d+)', webpage, 'show id')
176 videos = self._extract_videos(brand, show_id=show_id)
177 show_title = self._search_regex(r'data-show-title="([^
"]+)"', webpage, 'show title
', fatal=False)
180 entries.append(self.url_result(
181 video['url
'], 'Go
', video.get('id'), video.get('title
')))
183 return self.playlist_result(entries, show_id, show_title)
184 video_data = self._extract_videos(brand, video_id)[0]
185 video_id = video_data['id']
186 title = video_data['title
']
189 for asset in video_data.get('assets
', {}).get('asset
', []):
190 asset_url = asset.get('value
')
193 format_id = asset.get('format
')
194 ext = determine_ext(asset_url)
196 video_type = video_data.get('type')
198 'video_id
': video_data['id'],
199 'video_type
': video_type,
203 if video_data.get('accesslevel
') == '1':
204 requestor_id = site_info.get('requestor_id
', 'DisneyChannels
')
205 resource = site_info.get('resource_id
') or self._get_mvpd_resource(
206 requestor_id, title, video_id, None)
207 auth = self._extract_mvpd_auth(
208 url, video_id, requestor_id, resource)
212 'adobe_requestor_id
': requestor_id,
215 self._initialize_geo_bypass({'countries': ['US']})
216 entitlement = self._download_json(
217 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
218 video_id, data=urlencode_postdata(data))
219 errors = entitlement.get('errors
', {}).get('errors
', [])
222 if error.get('code
') == 1002:
223 self.raise_geo_restricted(
224 error['message
'], countries=['US
'])
225 error_message = ', '.join([error['message
'] for error in errors])
226 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
227 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
228 formats.extend(self._extract_m3u8_formats(
229 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False))
232 'format_id
': format_id,
236 if re.search(r'(?
:/mp4
/source
/|_source\
.mp4
)', asset_url):
238 'format_id
': ('%s-' % format_id if format_id else '') + 'SOURCE
',
242 mobj = re.search(r'/(\d
+)x(\d
+)/', asset_url)
244 height = int(mobj.group(2))
246 'format_id
': ('%s-' % format_id if format_id else '') + '%dP
' % height,
247 'width
': int(mobj.group(1)),
251 self._sort_formats(formats)
254 for cc in video_data.get('closedcaption
', {}).get('src
', []):
255 cc_url = cc.get('value
')
258 ext = determine_ext(cc_url)
261 subtitles.setdefault(cc.get('lang
'), []).append({
267 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
268 thumbnail_url = thumbnail.get('value
')
269 if not thumbnail_url:
272 'url
': thumbnail_url,
273 'width
': int_or_none(thumbnail.get('width
')),
274 'height
': int_or_none(thumbnail.get('height
')),
280 'description
': video_data.get('longdescription
') or video_data.get('description
'),
281 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
282 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
283 'episode_number
': int_or_none(video_data.get('episodenumber
')),
284 'series
': video_data.get('show
', {}).get('title
'),
285 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
286 'thumbnails
': thumbnails,
288 'subtitles
': subtitles,