2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class GoIE(InfoExtractor):
18 'watchdisneychannel': '004',
19 'watchdisneyjunior': '008',
20 'watchdisneyxd': '009',
22 _VALID_URL = r'https?://(?:(?P<sub_domain>%s)\.)?go\.com/.*?vdka(?P<id>\w+)' % '|'.join(_BRANDS.keys())
24 'url': 'http://abc.go.com/shows/castle/video/most-recent/vdka0_g86w5onx',
28 'title': 'Sneak Peek: Language Arts',
29 'description': 'md5:7dcdab3b2d17e5217c953256af964e9c',
33 'skip_download': True,
36 'url': 'http://abc.go.com/shows/after-paradise/video/most-recent/vdka3335601',
37 'only_matching': True,
40 def _real_extract(self, url):
41 sub_domain, video_id = re.match(self._VALID_URL, url).groups()
42 video_data = self._download_json(
43 'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/%s/001/-1/-1/-1/%s/-1/-1.json' % (self._BRANDS[sub_domain], video_id),
45 title = video_data['title']
48 for asset in video_data.get('assets', {}).get('asset', []):
49 asset_url = asset.get('value')
52 format_id = asset.get('format')
53 ext = determine_ext(asset_url)
55 formats.extend(self._extract_m3u8_formats(
56 asset_url, video_id, 'mp4', m3u8_id=format_id or 'hls', fatal=False))
59 'format_id': format_id,
63 self._sort_formats(formats)
66 for cc in video_data.get('closedcaption', {}).get('src', []):
67 cc_url = cc.get('value')
70 ext = determine_ext(cc_url)
73 subtitles.setdefault(cc.get('lang'), []).append({
79 for thumbnail in video_data.get('thumbnails', {}).get('thumbnail', []):
80 thumbnail_url = thumbnail.get('value')
85 'width': int_or_none(thumbnail.get('width')),
86 'height': int_or_none(thumbnail.get('height')),
92 'description': video_data.get('longdescription') or video_data.get('description'),
93 'duration': int_or_none(video_data.get('duration', {}).get('value'), 1000),
94 'age_limit': parse_age_limit(video_data.get('tvrating', {}).get('rating')),
95 'episode_number': int_or_none(video_data.get('episodenumber')),
96 'series': video_data.get('show', {}).get('title'),
97 'season_number': int_or_none(video_data.get('season', {}).get('num')),
98 'thumbnails': thumbnails,
100 'subtitles': subtitles,