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 'requestor_id': 'Disney',
30 'watchdisneyjunior': {
32 'requestor_id': 'DisneyJunior',
36 'requestor_id': 'DisneyXD',
39 _VALID_URL = r'https?://(?:(?P<sub_domain>%s)\.)?go\.com/(?:[^/]+/)*(?:vdka(?P<id>\w+)|season-\d+/\d+-(?P<display_id>[^/?#]+))' % '|'.join(_SITE_INFO.keys())
40 _GEO_COUNTRIES = ['US']
42 'url': 'http://abc.go.com/shows/castle/video/most-recent/vdka0_g86w5onx',
46 'title': 'Sneak Peek: Language Arts',
47 'description': 'md5:7dcdab3b2d17e5217c953256af964e9c',
51 'skip_download': True,
54 'url': 'http://abc.go.com/shows/after-paradise/video/most-recent/vdka3335601',
55 'only_matching': True,
58 def _real_extract(self, url):
59 sub_domain, video_id, display_id = re.match(self._VALID_URL, url).groups()
61 webpage = self._download_webpage(url, display_id)
62 video_id = self._search_regex(
63 # There may be inner quotes, e.g. data-video-id="'VDKA3609139'"
64 # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood
65 r'data-video-id=["\']*VDKA(\w+)', webpage, 'video id')
66 site_info = self._SITE_INFO[sub_domain]
67 brand = site_info['brand']
68 video_data = self._download_json(
69 'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/%s/001/-1/-1/-1/%s/-1/-1.json' % (brand, video_id),
71 title = video_data['title']
74 for asset in video_data.get('assets', {}).get('asset', []):
75 asset_url = asset.get('value')
78 format_id = asset.get('format')
79 ext = determine_ext(asset_url)
81 video_type = video_data.get('type')
82 if video_type == 'lf':
84 'video_id': video_data['id'],
85 'video_type': video_type,
89 if video_data.get('accesslevel') == '1':
90 requestor_id = site_info['requestor_id']
91 resource = self._get_mvpd_resource(
92 requestor_id, title, video_id, None)
93 auth = self._extract_mvpd_auth(
94 url, video_id, requestor_id, resource)
98 'adobe_requestor_id': requestor_id,
100 entitlement = self._download_json(
101 'https://api.entitlement.watchabc.go.com/vp2/ws-secure/entitlement/2020/authorize.json',
102 video_id, data=urlencode_postdata(data), headers=self.geo_verification_headers())
103 errors = entitlement.get('errors', {}).get('errors', [])
106 if error.get('code') == 1002:
107 self.raise_geo_restricted(
108 error['message'], countries=self._GEO_COUNTRIES)
109 error_message = ', '.join([error['message'] for error in errors])
110 raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message), expected=True)
111 asset_url += '?' + entitlement['uplynkData']['sessionKey']
112 formats.extend(self._extract_m3u8_formats(
113 asset_url, video_id, 'mp4', m3u8_id=format_id or 'hls', fatal=False))
116 'format_id': format_id,
120 self._sort_formats(formats)
123 for cc in video_data.get('closedcaption', {}).get('src', []):
124 cc_url = cc.get('value')
127 ext = determine_ext(cc_url)
130 subtitles.setdefault(cc.get('lang'), []).append({
136 for thumbnail in video_data.get('thumbnails', {}).get('thumbnail', []):
137 thumbnail_url = thumbnail.get('value')
138 if not thumbnail_url:
141 'url': thumbnail_url,
142 'width': int_or_none(thumbnail.get('width')),
143 'height': int_or_none(thumbnail.get('height')),
149 'description': video_data.get('longdescription') or video_data.get('description'),
150 'duration': int_or_none(video_data.get('duration', {}).get('value'), 1000),
151 'age_limit': parse_age_limit(video_data.get('tvrating', {}).get('rating')),
152 'episode_number': int_or_none(video_data.get('episodenumber')),
153 'series': video_data.get('show', {}).get('title'),
154 'season_number': int_or_none(video_data.get('season', {}).get('num')),
155 'thumbnails': thumbnails,
157 'subtitles': subtitles,