diff --git a/youtube_dl/extractor/go.py b/youtube_dl/extractor/go.py index a34779b16..92eca9cfb 100644 --- a/youtube_dl/extractor/go.py +++ b/youtube_dl/extractor/go.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import re -from .common import InfoExtractor +from .adobepass import AdobePassIE from ..utils import ( int_or_none, determine_ext, @@ -13,7 +13,7 @@ from ..utils import ( ) -class GoIE(InfoExtractor): +class GoIE(AdobePassIE): _BRANDS = { 'abc': '001', 'freeform': '002', @@ -43,16 +43,29 @@ class GoIE(InfoExtractor): sub_domain, video_id, display_id = re.match(self._VALID_URL, url).groups() if not video_id: webpage = self._download_webpage(url, display_id) - video_id = self._search_regex( - # There may be inner quotes, e.g. data-video-id="'VDKA3609139'" - # from http://freeform.go.com/shows/shadowhunters/episodes/season-2/1-this-guilty-blood - r'data-video-id=["\']*VDKA(\w+)', webpage, 'video id') + video_id = self._search_regex(r'data-video-id=["\']VDKA(\w+)', webpage, 'video id') brand = self._BRANDS[sub_domain] video_data = self._download_json( 'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/%s/001/-1/-1/-1/%s/-1/-1.json' % (brand, video_id), video_id)['video'][0] title = video_data['title'] + authdata = {} + if video_data['accesslevel'] == '1': + resource = self._get_mvpd_resource( + 'DisneyXD', title, video_id, + video_data.get('tvrating', {}).get('rating')) + token = self._extract_mvpd_auth( + url, video_id, 'DisneyXD', resource) + authdata.update({ + 'adobe_resource_id': resource, + 'token': token, + 'auth_flag': 1, + 'token_type': 'ap', + 'mvpd': title, + 'adobe_requestor_id': 'DisneyXD', + }) + formats = [] for asset in video_data.get('assets', {}).get('asset', []): asset_url = asset.get('value') @@ -63,14 +76,15 @@ class GoIE(InfoExtractor): if ext == 'm3u8': video_type = video_data.get('type') if video_type == 'lf': + authdata.update({ + 'video_id': video_data['id'], + 'video_type': video_type, + 'brand': brand, + 'device': '001', + }) entitlement = self._download_json( 'https://api.entitlement.watchabc.go.com/vp2/ws-secure/entitlement/2020/authorize.json', - video_id, data=urlencode_postdata({ - 'video_id': video_data['id'], - 'video_type': video_type, - 'brand': brand, - 'device': '001', - })) + video_id, data=urlencode_postdata(authdata)) errors = entitlement.get('errors', {}).get('errors', []) if errors: error_message = ', '.join([error['message'] for error in errors])