]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/go.py
2 from __future__
import unicode_literals
6 from .adobepass
import AdobePassIE
7 from ..compat
import compat_str
20 class GoIE(AdobePassIE
):
24 'requestor_id': 'ABC',
28 'requestor_id': 'ABCFamily',
30 'watchdisneychannel': {
32 'resource_id': 'Disney',
34 'watchdisneyjunior': {
36 'resource_id': 'DisneyJunior',
40 'resource_id': 'DisneyXD',
44 'resource_id': 'Disney',
48 'requestor_id': 'dtci',
54 (?:%s\.)?go|fxnow\.fxnetworks|
55 (?:www\.)?(?:abc|freeform|disneynow)
58 (?:[^/]+/)*(?P<id>[Vv][Dd][Kk][Aa]\w+)|
59 (?:[^/]+/)*(?P<display_id>[^/?\#]+)
61 ''' % r
'\.|'.join(list(_SITE_INFO
.keys()))
63 'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
67 'title': 'The Traitor in the White House',
68 'description': 'md5:05b009d2d145a1e85d25111bd37222e8',
72 'skip_download': True,
74 'skip': 'This content is no longer available.',
76 'url': 'http://watchdisneyxd.go.com/doraemon',
81 'playlist_mincount': 51,
83 'url': 'http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood',
87 'title': 'This Guilty Blood',
88 'description': 'md5:f18e79ad1c613798d95fdabfe96cd292',
92 'geo_bypass_ip_block': '3.244.239.0/24',
94 'skip_download': True,
97 'url': 'https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet',
102 'description': 'md5:c66de8ba2e92c6c5c113c3ade84ab404',
106 'geo_bypass_ip_block': '3.244.239.0/24',
108 'skip_download': True,
111 'url': 'https://fxnow.fxnetworks.com/shows/better-things/video/vdka12782841',
113 'id': 'VDKA12782841',
115 'title': 'First Look: Better Things - Season 2',
116 'description': 'md5:fa73584a95761c605d9d54904e35b407',
119 'geo_bypass_ip_block': '3.244.239.0/24',
121 'skip_download': True,
124 'url': 'https://abc.com/shows/modern-family/episode-guide/season-01/101-pilot',
126 'id': 'VDKA22600213',
129 'description': 'md5:74306df917cfc199d76d061d66bebdb4',
133 'skip_download': True,
136 'url': 'http://abc.go.com/shows/the-catch/episode-guide/season-01/10-the-wedding',
137 'only_matching': True,
139 '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',
140 'only_matching': True,
143 'url': 'http://disneynow.go.com/shows/big-hero-6-the-series/season-01/episode-10-mr-sparkles-loses-his-sparkle/vdka4637915',
144 'only_matching': True,
147 'url': 'http://disneynow.go.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
148 'only_matching': True,
150 'url': 'https://disneynow.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
151 'only_matching': True,
153 'url': 'https://www.freeform.com/shows/cruel-summer/episode-guide/season-01/01-happy-birthday-jeanette-turner',
154 'only_matching': True,
157 def _extract_videos(self
, brand
, video_id
='-1', show_id
='-1'):
158 display_id
= video_id
if video_id
!= '-1' else show_id
159 return self
._download
_json
(
160 '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
),
163 def _real_extract(self
, url
):
164 mobj
= re
.match(self
._VALID
_URL
, url
)
165 sub_domain
= remove_start(remove_end(mobj
.group('sub_domain') or '', '.go'), 'www.')
166 video_id
, display_id
= mobj
.group('id', 'display_id')
167 site_info
= self
._SITE
_INFO
.get(sub_domain
, {})
168 brand
= site_info
.get('brand')
169 if not video_id
or not site_info
:
170 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
171 data
= self
._parse
_json
(
173 r
'["\']__abc_com__
["\']\s*\]\s*=\s*({.+?})\s*;', webpage,
174 'data', default='{}'),
175 display_id or video_id, fatal=False)
176 # https://abc.com/shows/modern-family/episode-guide/season-01/101-pilot
177 layout = try_get(data, lambda x: x['page']['content']['video']['layout'], dict)
182 (lambda x: x['videoid'], lambda x: x['video']['id']),
185 video_id = self._search_regex(
187 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
188 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
189 r'data-video-id=["\']*(VDKA\w
+)',
190 # page.analytics.videoIdCode
191 r'\bvideoIdCode
["\']\s*:\s*["\']((?
:vdka|VDKA
)\w
+)',
192 # https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet
193 r'\b(?
:video
)?
id["\']\s*:\s*["\'](VDKA\w
+)'
194 ), webpage, 'video
id', default=video_id)
196 brand = self._search_regex(
197 (r'data
-brand
=\s
*["\']\s*(\d+)',
198 r'data-page-brand=\s*["\']\s
*(\d
+)'), webpage, 'brand
',
201 si for _, si in self._SITE_INFO.items()
202 if si.get('brand
') == brand)
204 # show extraction works for Disney, DisneyJunior and DisneyXD
205 # ABC and Freeform has different layout
206 show_id = self._search_regex(r'data
-show
-id=["\']*(SH\d+)', webpage, 'show id')
207 videos = self._extract_videos(brand, show_id=show_id)
208 show_title = self._search_regex(r'data-show-title="([^
"]+)"', webpage, 'show title
', fatal=False)
211 entries.append(self.url_result(
212 video['url
'], 'Go
', video.get('id'), video.get('title
')))
214 return self.playlist_result(entries, show_id, show_title)
215 video_data = self._extract_videos(brand, video_id)[0]
216 video_id = video_data['id']
217 title = video_data['title
']
220 for asset in video_data.get('assets
', {}).get('asset
', []):
221 asset_url = asset.get('value
')
224 format_id = asset.get('format
')
225 ext = determine_ext(asset_url)
227 video_type = video_data.get('type')
229 'video_id
': video_data['id'],
230 'video_type
': video_type,
234 if video_data.get('accesslevel
') == '1':
235 requestor_id = site_info.get('requestor_id
', 'DisneyChannels
')
236 resource = site_info.get('resource_id
') or self._get_mvpd_resource(
237 requestor_id, title, video_id, None)
238 auth = self._extract_mvpd_auth(
239 url, video_id, requestor_id, resource)
243 'adobe_requestor_id
': requestor_id,
246 self._initialize_geo_bypass({'countries': ['US']})
247 entitlement = self._download_json(
248 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
249 video_id, data=urlencode_postdata(data))
250 errors = entitlement.get('errors
', {}).get('errors
', [])
253 if error.get('code
') == 1002:
254 self.raise_geo_restricted(
255 error['message
'], countries=['US
'])
256 error_message = ', '.join([error['message
'] for error in errors])
257 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
258 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
259 formats.extend(self._extract_m3u8_formats(
260 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False))
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)
285 for cc in video_data.get('closedcaption
', {}).get('src
', []):
286 cc_url = cc.get('value
')
289 ext = determine_ext(cc_url)
292 subtitles.setdefault(cc.get('lang
'), []).append({
298 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
299 thumbnail_url = thumbnail.get('value
')
300 if not thumbnail_url:
303 'url
': thumbnail_url,
304 'width
': int_or_none(thumbnail.get('width
')),
305 'height
': int_or_none(thumbnail.get('height
')),
311 'description
': video_data.get('longdescription
') or video_data.get('description
'),
312 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
313 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
314 'episode_number
': int_or_none(video_data.get('episodenumber
')),
315 'series
': video_data.get('show
', {}).get('title
'),
316 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
317 'thumbnails
': thumbnails,
319 'subtitles
': subtitles,