]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/go.py
03e48f4ea4b93153ef445f0d9a66779144821361
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',
43 _VALID_URL
= r
'https?://(?:(?:(?P<sub_domain>%s)\.)?go|(?P<sub_domain_2>disneynow))\.com/(?:(?:[^/]+/)*(?P<id>vdka\w+)|(?:[^/]+/)*(?P<display_id>[^/?#]+))'\
44 % '|'.join(list(_SITE_INFO
.keys()) + ['disneynow'])
46 'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
50 'title': 'The Traitor in the White House',
51 'description': 'md5:05b009d2d145a1e85d25111bd37222e8',
55 'skip_download': True,
58 'url': 'http://watchdisneyxd.go.com/doraemon',
63 'playlist_mincount': 51,
65 'url': 'http://abc.go.com/shows/the-catch/episode-guide/season-01/10-the-wedding',
66 'only_matching': True,
68 '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',
69 'only_matching': True,
72 'url': 'http://disneynow.go.com/shows/big-hero-6-the-series/season-01/episode-10-mr-sparkles-loses-his-sparkle/vdka4637915',
73 'only_matching': True,
76 'url': 'http://disneynow.go.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
77 'only_matching': True,
79 'url': 'https://disneynow.com/shows/minnies-bow-toons/video/happy-campers/vdka4872013',
80 'only_matching': True,
83 def _extract_videos(self
, brand
, video_id
='-1', show_id
='-1'):
84 display_id
= video_id
if video_id
!= '-1' else show_id
85 return self
._download
_json
(
86 '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
),
89 def _real_extract(self
, url
):
90 mobj
= re
.match(self
._VALID
_URL
, url
)
91 sub_domain
= mobj
.group('sub_domain') or mobj
.group('sub_domain_2')
92 video_id
, display_id
= mobj
.group('id', 'display_id')
93 site_info
= self
._SITE
_INFO
.get(sub_domain
, {})
94 brand
= site_info
.get('brand')
95 if not video_id
or not site_info
:
96 webpage
= self
._download
_webpage
(url
, display_id
or video_id
)
97 video_id
= self
._search
_regex
(
98 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
99 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
100 r
'data-video-id=["\']*(VDKA\w
+)', webpage, 'video
id',
103 brand = self._search_regex(
104 (r'data
-brand
=\s
*["\']\s*(\d+)',
105 r'data-page-brand=\s*["\']\s
*(\d
+)'), webpage, 'brand
',
108 si for _, si in self._SITE_INFO.items()
109 if si.get('brand
') == brand)
111 # show extraction works for Disney, DisneyJunior and DisneyXD
112 # ABC and Freeform has different layout
113 show_id = self._search_regex(r'data
-show
-id=["\']*(SH\d+)', webpage, 'show id')
114 videos = self._extract_videos(brand, show_id=show_id)
115 show_title = self._search_regex(r'data-show-title="([^
"]+)"', webpage, 'show title
', fatal=False)
118 entries.append(self.url_result(
119 video['url
'], 'Go
', video.get('id'), video.get('title
')))
121 return self.playlist_result(entries, show_id, show_title)
122 video_data = self._extract_videos(brand, video_id)[0]
123 video_id = video_data['id']
124 title = video_data['title
']
127 for asset in video_data.get('assets
', {}).get('asset
', []):
128 asset_url = asset.get('value
')
131 format_id = asset.get('format
')
132 ext = determine_ext(asset_url)
134 video_type = video_data.get('type')
136 'video_id
': video_data['id'],
137 'video_type
': video_type,
141 if video_data.get('accesslevel
') == '1':
142 requestor_id = site_info.get('requestor_id
', 'DisneyChannels
')
143 resource = site_info.get('resource_id
') or self._get_mvpd_resource(
144 requestor_id, title, video_id, None)
145 auth = self._extract_mvpd_auth(
146 url, video_id, requestor_id, resource)
150 'adobe_requestor_id
': requestor_id,
153 self._initialize_geo_bypass({'countries
': ['US
']})
154 entitlement = self._download_json(
155 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
156 video_id, data=urlencode_postdata(data))
157 errors = entitlement.get('errors
', {}).get('errors
', [])
160 if error.get('code
') == 1002:
161 self.raise_geo_restricted(
162 error['message
'], countries=['US
'])
163 error_message = ', '.join([error['message
'] for error in errors])
164 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
165 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
166 formats.extend(self._extract_m3u8_formats(
167 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False))
170 'format_id
': format_id,
174 if re.search(r'(?
:/mp4
/source
/|_source\
.mp4
)', asset_url):
176 'format_id
': ('%s-' % format_id if format_id else '') + 'SOURCE
',
180 mobj = re.search(r'/(\d
+)x(\d
+)/', asset_url)
182 height = int(mobj.group(2))
184 'format_id
': ('%s-' % format_id if format_id else '') + '%dP
' % height,
185 'width
': int(mobj.group(1)),
189 self._sort_formats(formats)
192 for cc in video_data.get('closedcaption
', {}).get('src
', []):
193 cc_url = cc.get('value
')
196 ext = determine_ext(cc_url)
199 subtitles.setdefault(cc.get('lang
'), []).append({
205 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
206 thumbnail_url = thumbnail.get('value
')
207 if not thumbnail_url:
210 'url
': thumbnail_url,
211 'width
': int_or_none(thumbnail.get('width
')),
212 'height
': int_or_none(thumbnail.get('height
')),
218 'description
': video_data.get('longdescription
') or video_data.get('description
'),
219 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
220 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
221 'episode_number
': int_or_none(video_data.get('episodenumber
')),
222 'series
': video_data.get('show
', {}).get('title
'),
223 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
224 'thumbnails
': thumbnails,
226 'subtitles
': subtitles,