]>
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',
46 (?:(?P<sub_domain>%s)\.)?go|
47 (?P<sub_domain_2>abc|freeform|disneynow)
50 (?:[^/]+/)*(?P<id>[Vv][Dd][Kk][Aa]\w+)|
51 (?:[^/]+/)*(?P<display_id>[^/?\#]+)
53 ''' % '|'.join(list(_SITE_INFO
.keys()))
55 'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
59 'title': 'The Traitor in the White House',
60 'description': 'md5:05b009d2d145a1e85d25111bd37222e8',
64 'skip_download': True,
66 'skip': 'This content is no longer available.',
68 'url': 'http://watchdisneyxd.go.com/doraemon',
73 'playlist_mincount': 51,
75 'url': 'http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood',
79 'title': 'This Guilty Blood',
80 'description': 'md5:f18e79ad1c613798d95fdabfe96cd292',
84 'geo_bypass_ip_block': '3.244.239.0/24',
86 'skip_download': True,
89 'url': 'https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet',
94 'description': 'md5:c66de8ba2e92c6c5c113c3ade84ab404',
98 'geo_bypass_ip_block': '3.244.239.0/24',
100 'skip_download': True,
103 'url': 'http://abc.go.com/shows/the-catch/episode-guide/season-01/10-the-wedding',
104 'only_matching': True,
106 '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',
107 'only_matching': True,
110 'url': 'http://disneynow.go.com/shows/big-hero-6-the-series/season-01/episode-10-mr-sparkles-loses-his-sparkle/vdka4637915',
111 'only_matching': True,
114 'url': 'http://disneynow.go.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
115 'only_matching': True,
117 'url': 'https://disneynow.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
118 'only_matching': True,
121 def _extract_videos(self
, brand
, video_id
='-1', show_id
='-1'):
122 display_id
= video_id
if video_id
!= '-1' else show_id
123 return self
._download
_json
(
124 '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
),
127 def _real_extract(self
, url
):
128 mobj
= re
.match(self
._VALID
_URL
, url
)
129 sub_domain
= mobj
.group('sub_domain') or mobj
.group('sub_domain_2')
130 video_id
, display_id
= mobj
.group('id', 'display_id')
131 site_info
= self
._SITE
_INFO
.get(sub_domain
, {})
132 brand
= site_info
.get('brand')
133 if not video_id
or not site_info
:
134 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
135 video_id
= self
._search
_regex
(
137 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
138 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
139 r
'data-video-id=["\']*(VDKA\w
+)',
140 # https://github.com/ytdl-org/youtube-dl/pull/25216/files
141 # The following is based on the pull request on the line above. Changed the ABC.com URL to a show available now.
142 # https://abc.com/shows/the-rookie/episode-guide/season-02/19-the-q-word
143 r'\bvideoIdCode
["\']\s*:\s*["\'](vdka\w
+)',
144 # Deprecated fallback pattern
145 r'\b(?
:video
)?
id["\']\s*:\s*["\'](VDKA\w
+)'
146 ), webpage, 'video
id', default=video_id)
148 brand = self._search_regex(
149 (r'data
-brand
=\s
*["\']\s*(\d+)',
150 r'data-page-brand=\s*["\']\s
*(\d
+)'), webpage, 'brand
',
153 si for _, si in self._SITE_INFO.items()
154 if si.get('brand
') == brand)
156 # show extraction works for Disney, DisneyJunior and DisneyXD
157 # ABC and Freeform has different layout
158 show_id = self._search_regex(r'data
-show
-id=["\']*(SH\d+)', webpage, 'show id')
159 videos = self._extract_videos(brand, show_id=show_id)
160 show_title = self._search_regex(r'data-show-title="([^
"]+)"', webpage, 'show title
', fatal=False)
163 entries.append(self.url_result(
164 video['url
'], 'Go
', video.get('id'), video.get('title
')))
166 return self.playlist_result(entries, show_id, show_title)
167 video_data = self._extract_videos(brand, video_id)[0]
168 video_id = video_data['id']
169 title = video_data['title
']
172 for asset in video_data.get('assets
', {}).get('asset
', []):
173 asset_url = asset.get('value
')
176 format_id = asset.get('format
')
177 ext = determine_ext(asset_url)
179 video_type = video_data.get('type')
181 'video_id
': video_data['id'],
182 'video_type
': video_type,
186 if video_data.get('accesslevel
') == '1':
187 requestor_id = site_info.get('requestor_id
', 'DisneyChannels
')
188 resource = site_info.get('resource_id
') or self._get_mvpd_resource(
189 requestor_id, title, video_id, None)
190 auth = self._extract_mvpd_auth(
191 url, video_id, requestor_id, resource)
195 'adobe_requestor_id
': requestor_id,
198 self._initialize_geo_bypass({'countries': ['US']})
199 entitlement = self._download_json(
200 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
201 video_id, data=urlencode_postdata(data))
202 errors = entitlement.get('errors
', {}).get('errors
', [])
205 if error.get('code
') == 1002:
206 self.raise_geo_restricted(
207 error['message
'], countries=['US
'])
208 error_message = ', '.join([error['message
'] for error in errors])
209 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
210 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
211 formats.extend(self._extract_m3u8_formats(
212 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False))
215 'format_id
': format_id,
219 if re.search(r'(?
:/mp4
/source
/|_source\
.mp4
)', asset_url):
221 'format_id
': ('%s-' % format_id if format_id else '') + 'SOURCE
',
225 mobj = re.search(r'/(\d
+)x(\d
+)/', asset_url)
227 height = int(mobj.group(2))
229 'format_id
': ('%s-' % format_id if format_id else '') + '%dP
' % height,
230 'width
': int(mobj.group(1)),
234 self._sort_formats(formats)
237 for cc in video_data.get('closedcaption
', {}).get('src
', []):
238 cc_url = cc.get('value
')
241 ext = determine_ext(cc_url)
244 subtitles.setdefault(cc.get('lang
'), []).append({
250 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
251 thumbnail_url = thumbnail.get('value
')
252 if not thumbnail_url:
255 'url
': thumbnail_url,
256 'width
': int_or_none(thumbnail.get('width
')),
257 'height
': int_or_none(thumbnail.get('height
')),
263 'description
': video_data.get('longdescription
') or video_data.get('description
'),
264 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
265 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
266 'episode_number
': int_or_none(video_data.get('episodenumber
')),
267 'series
': video_data.get('show
', {}).get('title
'),
268 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
269 'thumbnails
': thumbnails,
271 'subtitles
': subtitles,