4 from .common
import InfoExtractor
18 class AdobeTVBaseIE(InfoExtractor
):
19 def _call_api(self
, path
, video_id
, query
, note
=None):
20 return self
._download
_json
(
21 'http://tv.adobe.com/api/v4/' + path
,
22 video_id
, note
, query
=query
)['data']
24 def _parse_subtitles(self
, video_data
, url_key
):
26 for translation
in video_data
.get('translations', []):
27 vtt_path
= translation
.get(url_key
)
30 lang
= translation
.get('language_w3c') or ISO639Utils
.long2short(translation
['language_medium'])
31 subtitles
.setdefault(lang
, []).append({
37 def _parse_video_data(self
, video_data
):
38 video_id
= str(video_data
['id'])
39 title
= video_data
['title']
43 for source
in video_data
.get('videos', []):
44 source_url
= source
.get('url')
48 'format_id': source
.get('quality_level'),
49 'fps': int_or_none(source
.get('frame_rate')),
50 'height': int_or_none(source
.get('height')),
51 'tbr': int_or_none(source
.get('video_data_rate')),
52 'width': int_or_none(source
.get('width')),
55 original_filename
= source
.get('original_filename')
57 if not (f
.get('height') and f
.get('width')):
58 mobj
= re
.search(r
'_(\d+)x(\d+)', original_filename
)
61 'height': int(mobj
.group(2)),
62 'width': int(mobj
.group(1)),
64 if original_filename
.startswith('s3://') and not s3_extracted
:
66 'format_id': 'original',
68 'url': original_filename
.replace('s3://', 'https://s3.amazonaws.com/'),
76 'description': video_data
.get('description'),
77 'thumbnail': video_data
.get('thumbnail'),
78 'upload_date': unified_strdate(video_data
.get('start_date')),
79 'duration': parse_duration(video_data
.get('duration')),
80 'view_count': str_to_int(video_data
.get('playcount')),
82 'subtitles': self
._parse
_subtitles
(video_data
, 'vtt'),
86 class AdobeTVEmbedIE(AdobeTVBaseIE
):
87 IE_NAME
= 'adobetv:embed'
88 _VALID_URL
= r
'https?://tv\.adobe\.com/embed/\d+/(?P<id>\d+)'
90 'url': 'https://tv.adobe.com/embed/22/4153',
91 'md5': 'c8c0461bf04d54574fc2b4d07ac6783a',
95 'title': 'Creating Graphics Optimized for BlackBerry',
96 'description': 'md5:eac6e8dced38bdaae51cd94447927459',
97 'thumbnail': r
're:https?://.*\.jpg$',
98 'upload_date': '20091109',
104 def _real_extract(self
, url
):
105 video_id
= self
._match
_id
(url
)
107 video_data
= self
._call
_api
(
108 'episode/' + video_id
, video_id
, {'disclosure': 'standard'})[0]
109 return self
._parse
_video
_data
(video_data
)
112 class AdobeTVIE(AdobeTVBaseIE
):
114 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?watch/(?P<show_urlname>[^/]+)/(?P<id>[^/]+)'
117 'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/',
118 'md5': '9bc5727bcdd55251f35ad311ca74fa1e',
122 'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop',
123 'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311',
124 'thumbnail': r
're:https?://.*\.jpg$',
125 'upload_date': '20110914',
131 def _real_extract(self
, url
):
132 language
, show_urlname
, urlname
= self
._match
_valid
_url
(url
).groups()
136 video_data
= self
._call
_api
(
137 'episode/get', urlname
, {
138 'disclosure': 'standard',
139 'language': language
,
140 'show_urlname': show_urlname
,
143 return self
._parse
_video
_data
(video_data
)
146 class AdobeTVPlaylistBaseIE(AdobeTVBaseIE
):
149 def _fetch_page(self
, display_id
, query
, page
):
152 for element_data
in self
._call
_api
(
153 self
._RESOURCE
, display_id
, query
, f
'Download Page {page}'):
154 yield self
._process
_data
(element_data
)
156 def _extract_playlist_entries(self
, display_id
, query
):
157 return OnDemandPagedList(functools
.partial(
158 self
._fetch
_page
, display_id
, query
), self
._PAGE
_SIZE
)
161 class AdobeTVShowIE(AdobeTVPlaylistBaseIE
):
162 IE_NAME
= 'adobetv:show'
163 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?show/(?P<id>[^/]+)'
166 'url': 'http://tv.adobe.com/show/the-complete-picture-with-julieanne-kost',
169 'title': 'The Complete Picture with Julieanne Kost',
170 'description': 'md5:fa50867102dcd1aa0ddf2ab039311b27',
172 'playlist_mincount': 136,
174 _RESOURCE
= 'episode'
175 _process_data
= AdobeTVBaseIE
._parse
_video
_data
177 def _real_extract(self
, url
):
178 language
, show_urlname
= self
._match
_valid
_url
(url
).groups()
182 'disclosure': 'standard',
183 'language': language
,
184 'show_urlname': show_urlname
,
187 show_data
= self
._call
_api
(
188 'show/get', show_urlname
, query
)[0]
190 return self
.playlist_result(
191 self
._extract
_playlist
_entries
(show_urlname
, query
),
192 str_or_none(show_data
.get('id')),
193 show_data
.get('show_name'),
194 show_data
.get('show_description'))
197 class AdobeTVChannelIE(AdobeTVPlaylistBaseIE
):
198 IE_NAME
= 'adobetv:channel'
199 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?channel/(?P<id>[^/]+)(?:/(?P<category_urlname>[^/]+))?'
202 'url': 'http://tv.adobe.com/channel/development',
206 'playlist_mincount': 96,
210 def _process_data(self
, show_data
):
211 return self
.url_result(
212 show_data
['url'], 'AdobeTVShow', str_or_none(show_data
.get('id')))
214 def _real_extract(self
, url
):
215 language
, channel_urlname
, category_urlname
= self
._match
_valid
_url
(url
).groups()
219 'channel_urlname': channel_urlname
,
220 'language': language
,
223 query
['category_urlname'] = category_urlname
225 return self
.playlist_result(
226 self
._extract
_playlist
_entries
(channel_urlname
, query
),
230 class AdobeTVVideoIE(AdobeTVBaseIE
):
231 IE_NAME
= 'adobetv:video'
232 _VALID_URL
= r
'https?://video\.tv\.adobe\.com/v/(?P<id>\d+)'
233 _EMBED_REGEX
= [r
'<iframe[^>]+src=[\'"](?P<url>(?:https?:)?//video\.tv\.adobe\.com/v/\d+[^"]+)[\'"]']
236 # From https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners
237 'url': 'https://video.tv.adobe.com/v/2456/',
238 'md5': '43662b577c018ad707a63766462b1e87',
242 'title': 'New experience with Acrobat DC',
243 'description': 'New experience with Acrobat DC',
248 def _real_extract(self, url):
249 video_id = self._match_id(url)
250 webpage = self._download_webpage(url, video_id)
252 video_data = self._parse_json(self._search_regex(
253 r'var\s+bridge\s*=\s*([^;]+);', webpage, 'bridged data'), video_id)
254 title = video_data['title']
257 sources = video_data.get('sources') or []
258 for source in sources:
259 source_src = source.get('src')
263 'filesize': int_or_none(source.get('kilobytes') or None, invscale=1000),
264 'format_id': join_nonempty(source.get('format'), source.get('label')),
265 'height': int_or_none(source.get('height') or None),
266 'tbr': int_or_none(source.get('bitrate') or None),
267 'width': int_or_none(source.get('width') or None),
271 # For both metadata and downloaded files the duration varies among
272 # formats. I just pick the max one
273 duration = max(filter(None, [
274 float_or_none(source.get('duration'), scale=1000)
275 for source in sources]))
281 'description': video_data.get('description'),
282 'thumbnail': video_data.get('video', {}).get('poster'),
283 'duration': duration,
284 'subtitles': self._parse_subtitles(video_data, 'vttPath'),