]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/go.py
3 from .adobepass
import AdobePassIE
4 from ..compat
import compat_str
17 class GoIE(AdobePassIE
):
21 'requestor_id': 'ABC',
25 'requestor_id': 'ABCFamily',
27 'watchdisneychannel': {
29 'resource_id': 'Disney',
31 'watchdisneyjunior': {
33 'resource_id': 'DisneyJunior',
37 'resource_id': 'DisneyXD',
41 'resource_id': 'Disney',
45 'requestor_id': 'dtci',
51 (?:%s\.)?go|fxnow\.fxnetworks|
52 (?:www\.)?(?:abc|freeform|disneynow)
55 (?:[^/]+/)*(?P<id>[Vv][Dd][Kk][Aa]\w+)|
56 (?:[^/]+/)*(?P<display_id>[^/?\#]+)
58 ''' % r
'\.|'.join(list(_SITE_INFO
.keys()))
60 'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
64 'title': 'The Traitor in the White House',
65 'description': 'md5:05b009d2d145a1e85d25111bd37222e8',
69 'skip_download': True,
71 'skip': 'This content is no longer available.',
73 'url': 'http://watchdisneyxd.go.com/doraemon',
78 'playlist_mincount': 51,
80 'url': 'http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood',
84 'title': 'This Guilty Blood',
85 'description': 'md5:f18e79ad1c613798d95fdabfe96cd292',
89 'geo_bypass_ip_block': '3.244.239.0/24',
91 'skip_download': True,
94 'url': 'https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet',
99 'description': 'md5:c66de8ba2e92c6c5c113c3ade84ab404',
103 'geo_bypass_ip_block': '3.244.239.0/24',
105 'skip_download': True,
108 'url': 'https://fxnow.fxnetworks.com/shows/better-things/video/vdka12782841',
110 'id': 'VDKA12782841',
112 'title': 'First Look: Better Things - Season 2',
113 'description': 'md5:fa73584a95761c605d9d54904e35b407',
116 'geo_bypass_ip_block': '3.244.239.0/24',
118 'skip_download': True,
121 'url': 'https://abc.com/shows/modern-family/episode-guide/season-01/101-pilot',
123 'id': 'VDKA22600213',
126 'description': 'md5:74306df917cfc199d76d061d66bebdb4',
130 'skip_download': True,
133 'url': 'http://abc.go.com/shows/the-catch/episode-guide/season-01/10-the-wedding',
134 'only_matching': True,
136 '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',
137 'only_matching': True,
140 'url': 'http://disneynow.go.com/shows/big-hero-6-the-series/season-01/episode-10-mr-sparkles-loses-his-sparkle/vdka4637915',
141 'only_matching': True,
144 'url': 'http://disneynow.go.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
145 'only_matching': True,
147 'url': 'https://disneynow.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
148 'only_matching': True,
150 'url': 'https://www.freeform.com/shows/cruel-summer/episode-guide/season-01/01-happy-birthday-jeanette-turner',
151 'only_matching': True,
154 def _extract_videos(self
, brand
, video_id
='-1', show_id
='-1'):
155 display_id
= video_id
if video_id
!= '-1' else show_id
156 return self
._download
_json
(
157 '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
),
160 def _real_extract(self
, url
):
161 mobj
= self
._match
_valid
_url
(url
)
162 sub_domain
= remove_start(remove_end(mobj
.group('sub_domain') or '', '.go'), 'www.')
163 video_id
, display_id
= mobj
.group('id', 'display_id')
164 site_info
= self
._SITE
_INFO
.get(sub_domain
, {})
165 brand
= site_info
.get('brand')
166 if not video_id
or not site_info
:
167 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
168 data
= self
._parse
_json
(
170 r
'["\']__abc_com__
["\']\s*\]\s*=\s*({.+?})\s*;', webpage,
171 'data', default='{}'),
172 display_id or video_id, fatal=False)
173 # https://abc.com/shows/modern-family/episode-guide/season-01/101-pilot
174 layout = try_get(data, lambda x: x['page']['content']['video']['layout'], dict)
179 (lambda x: x['videoid'], lambda x: x['video']['id']),
182 video_id = self._search_regex(
184 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
185 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
186 r'data-video-id=["\']*(VDKA\w
+)',
187 # page.analytics.videoIdCode
188 r'\bvideoIdCode
["\']\s*:\s*["\']((?
:vdka|VDKA
)\w
+)',
189 # https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet
190 r'\b(?
:video
)?
id["\']\s*:\s*["\'](VDKA\w
+)'
191 ), webpage, 'video
id', default=video_id)
193 brand = self._search_regex(
194 (r'data
-brand
=\s
*["\']\s*(\d+)',
195 r'data-page-brand=\s*["\']\s
*(\d
+)'), webpage, 'brand
',
198 si for _, si in self._SITE_INFO.items()
199 if si.get('brand
') == brand)
201 # show extraction works for Disney, DisneyJunior and DisneyXD
202 # ABC and Freeform has different layout
203 show_id = self._search_regex(r'data
-show
-id=["\']*(SH\d+)', webpage, 'show id')
204 videos = self._extract_videos(brand, show_id=show_id)
205 show_title = self._search_regex(r'data-show-title="([^
"]+)"', webpage, 'show title
', fatal=False)
208 entries.append(self.url_result(
209 video['url
'], 'Go
', video.get('id'), video.get('title
')))
211 return self.playlist_result(entries, show_id, show_title)
212 video_data = self._extract_videos(brand, video_id)[0]
213 video_id = video_data['id']
214 title = video_data['title
']
218 for asset in video_data.get('assets
', {}).get('asset
', []):
219 asset_url = asset.get('value
')
222 format_id = asset.get('format
')
223 ext = determine_ext(asset_url)
225 video_type = video_data.get('type')
227 'video_id
': video_data['id'],
228 'video_type
': video_type,
232 if video_data.get('accesslevel
') == '1':
233 requestor_id = site_info.get('requestor_id
', 'DisneyChannels
')
234 resource = site_info.get('resource_id
') or self._get_mvpd_resource(
235 requestor_id, title, video_id, None)
236 auth = self._extract_mvpd_auth(
237 url, video_id, requestor_id, resource)
241 'adobe_requestor_id
': requestor_id,
244 self._initialize_geo_bypass({'countries': ['US']})
245 entitlement = self._download_json(
246 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
247 video_id, data=urlencode_postdata(data))
248 errors = entitlement.get('errors
', {}).get('errors
', [])
251 if error.get('code
') == 1002:
252 self.raise_geo_restricted(
253 error['message
'], countries=['US
'])
254 error_message = ', '.join([error['message
'] for error in errors])
255 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
256 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
257 fmts, subs = self._extract_m3u8_formats_and_subtitles(
258 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False)
260 self._merge_subtitles(subs, target=subtitles)
263 'format_id
': format_id,
267 if re.search(r'(?
:/mp4
/source
/|_source\
.mp4
)', asset_url):
269 'format_id
': ('%s-' % format_id if format_id else '') + 'SOURCE
',
273 mobj = re.search(r'/(\d
+)x(\d
+)/', asset_url)
275 height = int(mobj.group(2))
277 'format_id
': ('%s-' % format_id if format_id else '') + '%dP
' % height,
278 'width
': int(mobj.group(1)),
282 self._sort_formats(formats)
284 for cc in video_data.get('closedcaption
', {}).get('src
', []):
285 cc_url = cc.get('value
')
288 ext = determine_ext(cc_url)
291 subtitles.setdefault(cc.get('lang
'), []).append({
297 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
298 thumbnail_url = thumbnail.get('value
')
299 if not thumbnail_url:
302 'url
': thumbnail_url,
303 'width
': int_or_none(thumbnail.get('width
')),
304 'height
': int_or_none(thumbnail.get('height
')),
310 'description
': video_data.get('longdescription
') or video_data.get('description
'),
311 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
312 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
313 'episode_number
': int_or_none(video_data.get('episodenumber
')),
314 'series
': video_data.get('show
', {}).get('title
'),
315 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
316 'thumbnails
': thumbnails,
318 'subtitles
': subtitles,