1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
21 class AdobeTVBaseIE(InfoExtractor
):
22 def _call_api(self
, path
, video_id
, query
, note
=None):
23 return self
._download
_json
(
24 'http://tv.adobe.com/api/v4/' + path
,
25 video_id
, note
, query
=query
)['data']
27 def _parse_subtitles(self
, video_data
, url_key
):
29 for translation
in video_data
.get('translations', []):
30 vtt_path
= translation
.get(url_key
)
33 lang
= translation
.get('language_w3c') or ISO639Utils
.long2short(translation
['language_medium'])
34 subtitles
.setdefault(lang
, []).append({
40 def _parse_video_data(self
, video_data
):
41 video_id
= compat_str(video_data
['id'])
42 title
= video_data
['title']
46 for source
in video_data
.get('videos', []):
47 source_url
= source
.get('url')
51 'format_id': source
.get('quality_level'),
52 'fps': int_or_none(source
.get('frame_rate')),
53 'height': int_or_none(source
.get('height')),
54 'tbr': int_or_none(source
.get('video_data_rate')),
55 'width': int_or_none(source
.get('width')),
58 original_filename
= source
.get('original_filename')
60 if not (f
.get('height') and f
.get('width')):
61 mobj
= re
.search(r
'_(\d+)x(\d+)', original_filename
)
64 'height': int(mobj
.group(2)),
65 'width': int(mobj
.group(1)),
67 if original_filename
.startswith('s3://') and not s3_extracted
:
69 'format_id': 'original',
71 'url': original_filename
.replace('s3://', 'https://s3.amazonaws.com/'),
75 self
._sort
_formats
(formats
)
80 'description': video_data
.get('description'),
81 'thumbnail': video_data
.get('thumbnail'),
82 'upload_date': unified_strdate(video_data
.get('start_date')),
83 'duration': parse_duration(video_data
.get('duration')),
84 'view_count': str_to_int(video_data
.get('playcount')),
86 'subtitles': self
._parse
_subtitles
(video_data
, 'vtt'),
90 class AdobeTVEmbedIE(AdobeTVBaseIE
):
91 IE_NAME
= 'adobetv:embed'
92 _VALID_URL
= r
'https?://tv\.adobe\.com/embed/\d+/(?P<id>\d+)'
94 'url': 'https://tv.adobe.com/embed/22/4153',
95 'md5': 'c8c0461bf04d54574fc2b4d07ac6783a',
99 'title': 'Creating Graphics Optimized for BlackBerry',
100 'description': 'md5:eac6e8dced38bdaae51cd94447927459',
101 'thumbnail': r
're:https?://.*\.jpg$',
102 'upload_date': '20091109',
108 def _real_extract(self
, url
):
109 video_id
= self
._match
_id
(url
)
111 video_data
= self
._call
_api
(
112 'episode/' + video_id
, video_id
, {'disclosure': 'standard'}
)[0]
113 return self
._parse
_video
_data
(video_data
)
116 class AdobeTVIE(AdobeTVBaseIE
):
118 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?watch/(?P<show_urlname>[^/]+)/(?P<id>[^/]+)'
121 'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/',
122 'md5': '9bc5727bcdd55251f35ad311ca74fa1e',
126 'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop',
127 'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311',
128 'thumbnail': r
're:https?://.*\.jpg$',
129 'upload_date': '20110914',
135 def _real_extract(self
, url
):
136 language
, show_urlname
, urlname
= self
._match
_valid
_url
(url
).groups()
140 video_data
= self
._call
_api
(
141 'episode/get', urlname
, {
142 'disclosure': 'standard',
143 'language': language
,
144 'show_urlname': show_urlname
,
147 return self
._parse
_video
_data
(video_data
)
150 class AdobeTVPlaylistBaseIE(AdobeTVBaseIE
):
153 def _fetch_page(self
, display_id
, query
, page
):
156 for element_data
in self
._call
_api
(
157 self
._RESOURCE
, display_id
, query
, 'Download Page %d' % page
):
158 yield self
._process
_data
(element_data
)
160 def _extract_playlist_entries(self
, display_id
, query
):
161 return OnDemandPagedList(functools
.partial(
162 self
._fetch
_page
, display_id
, query
), self
._PAGE
_SIZE
)
165 class AdobeTVShowIE(AdobeTVPlaylistBaseIE
):
166 IE_NAME
= 'adobetv:show'
167 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?show/(?P<id>[^/]+)'
170 'url': 'http://tv.adobe.com/show/the-complete-picture-with-julieanne-kost',
173 'title': 'The Complete Picture with Julieanne Kost',
174 'description': 'md5:fa50867102dcd1aa0ddf2ab039311b27',
176 'playlist_mincount': 136,
178 _RESOURCE
= 'episode'
179 _process_data
= AdobeTVBaseIE
._parse
_video
_data
181 def _real_extract(self
, url
):
182 language
, show_urlname
= self
._match
_valid
_url
(url
).groups()
186 'disclosure': 'standard',
187 'language': language
,
188 'show_urlname': show_urlname
,
191 show_data
= self
._call
_api
(
192 'show/get', show_urlname
, query
)[0]
194 return self
.playlist_result(
195 self
._extract
_playlist
_entries
(show_urlname
, query
),
196 str_or_none(show_data
.get('id')),
197 show_data
.get('show_name'),
198 show_data
.get('show_description'))
201 class AdobeTVChannelIE(AdobeTVPlaylistBaseIE
):
202 IE_NAME
= 'adobetv:channel'
203 _VALID_URL
= r
'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?channel/(?P<id>[^/]+)(?:/(?P<category_urlname>[^/]+))?'
206 'url': 'http://tv.adobe.com/channel/development',
210 'playlist_mincount': 96,
214 def _process_data(self
, show_data
):
215 return self
.url_result(
216 show_data
['url'], 'AdobeTVShow', str_or_none(show_data
.get('id')))
218 def _real_extract(self
, url
):
219 language
, channel_urlname
, category_urlname
= self
._match
_valid
_url
(url
).groups()
223 'channel_urlname': channel_urlname
,
224 'language': language
,
227 query
['category_urlname'] = category_urlname
229 return self
.playlist_result(
230 self
._extract
_playlist
_entries
(channel_urlname
, query
),
234 class AdobeTVVideoIE(AdobeTVBaseIE
):
235 IE_NAME
= 'adobetv:video'
236 _VALID_URL
= r
'https?://video\.tv\.adobe\.com/v/(?P<id>\d+)'
239 # From https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners
240 'url': 'https://video.tv.adobe.com/v/2456/',
241 'md5': '43662b577c018ad707a63766462b1e87',
245 'title': 'New experience with Acrobat DC',
246 'description': 'New experience with Acrobat DC',
251 def _real_extract(self
, url
):
252 video_id
= self
._match
_id
(url
)
253 webpage
= self
._download
_webpage
(url
, video_id
)
255 video_data
= self
._parse
_json
(self
._search
_regex
(
256 r
'var\s+bridge\s*=\s*([^;]+);', webpage
, 'bridged data'), video_id
)
257 title
= video_data
['title']
260 sources
= video_data
.get('sources') or []
261 for source
in sources
:
262 source_src
= source
.get('src')
266 'filesize': int_or_none(source
.get('kilobytes') or None, invscale
=1000),
267 'format_id': join_nonempty(source
.get('format'), source
.get('label')),
268 'height': int_or_none(source
.get('height') or None),
269 'tbr': int_or_none(source
.get('bitrate') or None),
270 'width': int_or_none(source
.get('width') or None),
273 self
._sort
_formats
(formats
)
275 # For both metadata and downloaded files the duration varies among
276 # formats. I just pick the max one
277 duration
= max(filter(None, [
278 float_or_none(source
.get('duration'), scale
=1000)
279 for source
in sources
]))
285 'description': video_data
.get('description'),
286 'thumbnail': video_data
.get('video', {}).get('poster'),
287 'duration': duration
,
288 'subtitles': self
._parse
_subtitles
(video_data
, 'vttPath'),