]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/go.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class GoIE(InfoExtractor
):
20 'watchdisneychannel': '004',
21 'watchdisneyjunior': '008',
22 'watchdisneyxd': '009',
24 _VALID_URL
= r
'https?://(?:(?P<sub_domain>%s)\.)?go\.com/(?:[^/]+/)*(?:vdka(?P<id>\w+)|season-\d+/\d+-(?P<display_id>[^/?#]+))' % '|'.join(_BRANDS
.keys())
26 'url': 'http://abc.go.com/shows/castle/video/most-recent/vdka0_g86w5onx',
30 'title': 'Sneak Peek: Language Arts',
31 'description': 'md5:7dcdab3b2d17e5217c953256af964e9c',
35 'skip_download': True,
38 'url': 'http://abc.go.com/shows/after-paradise/video/most-recent/vdka3335601',
39 'only_matching': True,
42 def _real_extract(self
, url
):
43 sub_domain
, video_id
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
45 webpage
= self
._download
_webpage
(url
, display_id
)
46 video_id
= self
._search
_regex
(r
'data-video-id=["\']VDKA(\w
+)', webpage, 'video
id')
47 brand = self._BRANDS[sub_domain]
48 video_data = self._download_json(
49 'http
://api
.contents
.watchabc
.go
.com
/vp2
/ws
/contents
/3000/videos
/%s/001/-1/-1/-1/%s/-1/-1.json
' % (brand, video_id),
51 title = video_data['title
']
54 for asset in video_data.get('assets
', {}).get('asset
', []):
55 asset_url = asset.get('value
')
58 format_id = asset.get('format
')
59 ext = determine_ext(asset_url)
61 video_type = video_data.get('type')
62 if video_type == 'lf
':
63 entitlement = self._download_json(
64 'https
://api
.entitlement
.watchabc
.go
.com
/vp2
/ws
-secure
/entitlement
/2020/authorize
.json
',
65 video_id, data=urlencode_postdata({
66 'video_id
': video_data['id'],
67 'video_type
': video_type,
71 errors = entitlement.get('errors
', {}).get('errors
', [])
73 error_message = ', '.join([error['message
'] for error in errors])
74 raise ExtractorError('%s said
: %s' % (self.IE_NAME, error_message), expected=True)
75 asset_url += '?
' + entitlement['uplynkData
']['sessionKey
']
76 formats.extend(self._extract_m3u8_formats(
77 asset_url, video_id, 'mp4
', m3u8_id=format_id or 'hls
', fatal=False))
80 'format_id
': format_id,
84 self._sort_formats(formats)
87 for cc in video_data.get('closedcaption
', {}).get('src
', []):
88 cc_url = cc.get('value
')
91 ext = determine_ext(cc_url)
94 subtitles.setdefault(cc.get('lang
'), []).append({
100 for thumbnail in video_data.get('thumbnails
', {}).get('thumbnail
', []):
101 thumbnail_url = thumbnail.get('value
')
102 if not thumbnail_url:
105 'url
': thumbnail_url,
106 'width
': int_or_none(thumbnail.get('width
')),
107 'height
': int_or_none(thumbnail.get('height
')),
113 'description
': video_data.get('longdescription
') or video_data.get('description
'),
114 'duration
': int_or_none(video_data.get('duration
', {}).get('value
'), 1000),
115 'age_limit
': parse_age_limit(video_data.get('tvrating
', {}).get('rating
')),
116 'episode_number
': int_or_none(video_data.get('episodenumber
')),
117 'series
': video_data.get('show
', {}).get('title
'),
118 'season_number
': int_or_none(video_data.get('season
', {}).get('num
')),
119 'thumbnails
': thumbnails,
121 'subtitles
': subtitles,