1 from __future__ import unicode_literals
5 from .common import InfoExtractor
17 class AdobeTVBaseIE(InfoExtractor):
18 _API_BASE_URL = 'http://tv.adobe.com/api/v4/'
21 class AdobeTVIE(AdobeTVBaseIE):
22 _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?watch/(?P<show_urlname>[^/]+)/(?P<id>[^/]+)'
25 'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/',
26 'md5': '9bc5727bcdd55251f35ad311ca74fa1e',
30 'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop',
31 'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311',
32 'thumbnail': 're:https?://.*\.jpg$',
33 'upload_date': '20110914',
39 def _real_extract(self, url):
40 language, show_urlname, urlname = re.match(self._VALID_URL, url).groups()
44 video_data = self._download_json(
45 self._API_BASE_URL + 'episode/get/?language=%s&show_urlname=%s&urlname=%s&disclosure=standard' % (language, show_urlname, urlname),
50 'format_id': source.get('quality_level') or source['url'].split('-')[-1].split('.')[0] or None,
51 'width': int_or_none(source.get('width')),
52 'height': int_or_none(source.get('height')),
53 'tbr': int_or_none(source.get('video_data_rate')),
54 } for source in video_data['videos']]
55 self._sort_formats(formats)
58 'id': str(video_data['id']),
59 'title': video_data['title'],
60 'description': video_data.get('description'),
61 'thumbnail': video_data.get('thumbnail'),
62 'upload_date': unified_strdate(video_data.get('start_date')),
63 'duration': parse_duration(video_data.get('duration')),
64 'view_count': str_to_int(video_data.get('playcount')),
69 class AdobeTVPlaylistBaseIE(AdobeTVBaseIE):
70 def _parse_page_data(self, page_data):
71 return [self.url_result(self._get_element_url(element_data)) for element_data in page_data]
73 def _extract_playlist_entries(self, url, display_id):
74 page = self._download_json(url, display_id)
75 entries = self._parse_page_data(page['data'])
76 for page_num in range(2, page['paging']['pages'] + 1):
77 entries.extend(self._parse_page_data(
78 self._download_json(url + '&page=%d' % page_num, display_id)['data']))
82 class AdobeTVShowIE(AdobeTVPlaylistBaseIE):
83 _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?show/(?P<id>[^/]+)'
86 'url': 'http://tv.adobe.com/show/the-complete-picture-with-julieanne-kost',
89 'title': 'The Complete Picture with Julieanne Kost',
90 'description': 'md5:fa50867102dcd1aa0ddf2ab039311b27',
92 'playlist_mincount': 136,
95 def _get_element_url(self, element_data):
96 return element_data['urls'][0]
98 def _real_extract(self, url):
99 language, show_urlname = re.match(self._VALID_URL, url).groups()
102 query = 'language=%s&show_urlname=%s' % (language, show_urlname)
104 show_data = self._download_json(self._API_BASE_URL + 'show/get/?%s' % query, show_urlname)['data'][0]
106 return self.playlist_result(
107 self._extract_playlist_entries(self._API_BASE_URL + 'episode/?%s' % query, show_urlname),
108 str(show_data['id']),
109 show_data['show_name'],
110 show_data['show_description'])
113 class AdobeTVChannelIE(AdobeTVPlaylistBaseIE):
114 _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?channel/(?P<id>[^/]+)(?:/(?P<category_urlname>[^/]+))?'
117 'url': 'http://tv.adobe.com/channel/development',
121 'playlist_mincount': 96,
124 def _get_element_url(self, element_data):
125 return element_data['url']
127 def _real_extract(self, url):
128 language, channel_urlname, category_urlname = re.match(self._VALID_URL, url).groups()
131 query = 'language=%s&channel_urlname=%s' % (language, channel_urlname)
133 query += '&category_urlname=%s' % category_urlname
135 return self.playlist_result(
136 self._extract_playlist_entries(self._API_BASE_URL + 'show/?%s' % query, channel_urlname),
140 class AdobeTVVideoIE(InfoExtractor):
141 _VALID_URL = r'https?://video\.tv\.adobe\.com/v/(?P<id>\d+)'
144 # From https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners
145 'url': 'https://video.tv.adobe.com/v/2456/',
146 'md5': '43662b577c018ad707a63766462b1e87',
150 'title': 'New experience with Acrobat DC',
151 'description': 'New experience with Acrobat DC',
156 def _real_extract(self, url):
157 video_id = self._match_id(url)
158 video_data = self._download_json(url + '?format=json', video_id)
161 'format_id': '%s-%s' % (determine_ext(source['src']), source.get('height')),
162 'url': source['src'],
163 'width': int_or_none(source.get('width')),
164 'height': int_or_none(source.get('height')),
165 'tbr': int_or_none(source.get('bitrate')),
166 } for source in video_data['sources']]
167 self._sort_formats(formats)
169 # For both metadata and downloaded files the duration varies among
170 # formats. I just pick the max one
171 duration = max(filter(None, [
172 float_or_none(source.get('duration'), scale=1000)
173 for source in video_data['sources']]))
176 for translation in video_data.get('translations', []):
177 lang_id = translation.get('language_w3c') or ISO639Utils.long2short(translation['language_medium'])
178 if lang_id not in subtitles:
179 subtitles[lang_id] = []
180 subtitles[lang_id].append({
181 'url': translation['vttPath'],
188 'title': video_data['title'],
189 'description': video_data.get('description'),
190 'thumbnail': video_data['video'].get('poster'),
191 'duration': duration,
192 'subtitles': subtitles,