| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  | import re | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-12-04 08:44:18 +01:00
										 |  |  | from ..compat import compat_str | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     parse_duration, | 
					
						
							|  |  |  |     unified_strdate, | 
					
						
							|  |  |  |     str_to_int, | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  |     float_or_none, | 
					
						
							|  |  |  |     ISO639Utils, | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |     determine_ext, | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  | class AdobeTVBaseIE(InfoExtractor): | 
					
						
							|  |  |  |     _API_BASE_URL = 'http://tv.adobe.com/api/v4/' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AdobeTVIE(AdobeTVBaseIE): | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |     _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?watch/(?P<show_urlname>[^/]+)/(?P<id>[^/]+)' | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/', | 
					
						
							|  |  |  |         'md5': '9bc5727bcdd55251f35ad311ca74fa1e', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |             'id': '10981', | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop', | 
					
						
							|  |  |  |             'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311', | 
					
						
							|  |  |  |             'thumbnail': 're:https?://.*\.jpg$', | 
					
						
							|  |  |  |             'upload_date': '20110914', | 
					
						
							|  |  |  |             'duration': 60, | 
					
						
							|  |  |  |             'view_count': int, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |         language, show_urlname, urlname = re.match(self._VALID_URL, url).groups() | 
					
						
							|  |  |  |         if not language: | 
					
						
							|  |  |  |             language = 'en' | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |         video_data = self._download_json( | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  |             self._API_BASE_URL + 'episode/get/?language=%s&show_urlname=%s&urlname=%s&disclosure=standard' % (language, show_urlname, urlname), | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |             urlname)['data'][0] | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         formats = [{ | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |             'url': source['url'], | 
					
						
							|  |  |  |             'format_id': source.get('quality_level') or source['url'].split('-')[-1].split('.')[0] or None, | 
					
						
							|  |  |  |             'width': int_or_none(source.get('width')), | 
					
						
							|  |  |  |             'height': int_or_none(source.get('height')), | 
					
						
							|  |  |  |             'tbr': int_or_none(source.get('video_data_rate')), | 
					
						
							|  |  |  |         } for source in video_data['videos']] | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  |         self._sort_formats(formats) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							| 
									
										
										
										
											2015-12-04 08:44:18 +01:00
										 |  |  |             'id': compat_str(video_data['id']), | 
					
						
							| 
									
										
										
										
											2015-10-29 19:44:26 +01:00
										 |  |  |             'title': video_data['title'], | 
					
						
							|  |  |  |             'description': video_data.get('description'), | 
					
						
							|  |  |  |             'thumbnail': video_data.get('thumbnail'), | 
					
						
							|  |  |  |             'upload_date': unified_strdate(video_data.get('start_date')), | 
					
						
							|  |  |  |             'duration': parse_duration(video_data.get('duration')), | 
					
						
							|  |  |  |             'view_count': str_to_int(video_data.get('playcount')), | 
					
						
							| 
									
										
										
										
											2014-12-22 22:05:47 +06:00
										 |  |  |             'formats': formats, | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  | class AdobeTVPlaylistBaseIE(AdobeTVBaseIE): | 
					
						
							| 
									
										
										
										
											2015-10-29 20:00:27 +01:00
										 |  |  |     def _parse_page_data(self, page_data): | 
					
						
							|  |  |  |         return [self.url_result(self._get_element_url(element_data)) for element_data in page_data] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _extract_playlist_entries(self, url, display_id): | 
					
						
							|  |  |  |         page = self._download_json(url, display_id) | 
					
						
							|  |  |  |         entries = self._parse_page_data(page['data']) | 
					
						
							|  |  |  |         for page_num in range(2, page['paging']['pages'] + 1): | 
					
						
							|  |  |  |             entries.extend(self._parse_page_data( | 
					
						
							|  |  |  |                 self._download_json(url + '&page=%d' % page_num, display_id)['data'])) | 
					
						
							|  |  |  |         return entries | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AdobeTVShowIE(AdobeTVPlaylistBaseIE): | 
					
						
							|  |  |  |     _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?show/(?P<id>[^/]+)' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://tv.adobe.com/show/the-complete-picture-with-julieanne-kost', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '36', | 
					
						
							|  |  |  |             'title': 'The Complete Picture with Julieanne Kost', | 
					
						
							|  |  |  |             'description': 'md5:fa50867102dcd1aa0ddf2ab039311b27', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'playlist_mincount': 136, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _get_element_url(self, element_data): | 
					
						
							|  |  |  |         return element_data['urls'][0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         language, show_urlname = re.match(self._VALID_URL, url).groups() | 
					
						
							|  |  |  |         if not language: | 
					
						
							|  |  |  |             language = 'en' | 
					
						
							|  |  |  |         query = 'language=%s&show_urlname=%s' % (language, show_urlname) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  |         show_data = self._download_json(self._API_BASE_URL + 'show/get/?%s' % query, show_urlname)['data'][0] | 
					
						
							| 
									
										
										
										
											2015-10-29 20:00:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return self.playlist_result( | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  |             self._extract_playlist_entries(self._API_BASE_URL + 'episode/?%s' % query, show_urlname), | 
					
						
							| 
									
										
										
										
											2015-12-04 08:44:18 +01:00
										 |  |  |             compat_str(show_data['id']), | 
					
						
							| 
									
										
										
										
											2015-10-29 20:00:27 +01:00
										 |  |  |             show_data['show_name'], | 
					
						
							|  |  |  |             show_data['show_description']) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AdobeTVChannelIE(AdobeTVPlaylistBaseIE): | 
					
						
							|  |  |  |     _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?channel/(?P<id>[^/]+)(?:/(?P<category_urlname>[^/]+))?' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://tv.adobe.com/channel/development', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': 'development', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'playlist_mincount': 96, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _get_element_url(self, element_data): | 
					
						
							|  |  |  |         return element_data['url'] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         language, channel_urlname, category_urlname = re.match(self._VALID_URL, url).groups() | 
					
						
							|  |  |  |         if not language: | 
					
						
							|  |  |  |             language = 'en' | 
					
						
							|  |  |  |         query = 'language=%s&channel_urlname=%s' % (language, channel_urlname) | 
					
						
							|  |  |  |         if category_urlname: | 
					
						
							|  |  |  |             query += '&category_urlname=%s' % category_urlname | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return self.playlist_result( | 
					
						
							| 
									
										
										
										
											2015-12-04 08:37:08 +01:00
										 |  |  |             self._extract_playlist_entries(self._API_BASE_URL + 'show/?%s' % query, channel_urlname), | 
					
						
							| 
									
										
										
										
											2015-10-29 20:00:27 +01:00
										 |  |  |             channel_urlname) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  | class AdobeTVVideoIE(InfoExtractor): | 
					
						
							|  |  |  |     _VALID_URL = r'https?://video\.tv\.adobe\.com/v/(?P<id>\d+)' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2015-06-22 15:02:53 +08:00
										 |  |  |         # From https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  |         'url': 'https://video.tv.adobe.com/v/2456/', | 
					
						
							|  |  |  |         'md5': '43662b577c018ad707a63766462b1e87', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '2456', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'New experience with Acrobat DC', | 
					
						
							|  |  |  |             'description': 'New experience with Acrobat DC', | 
					
						
							|  |  |  |             'duration': 248.667, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2016-06-18 12:21:40 +08:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         video_data = self._parse_json(self._search_regex( | 
					
						
							|  |  |  |             r'var\s+bridge\s*=\s*([^;]+);', webpage, 'bridged data'), video_id) | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         formats = [{ | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |             'format_id': '%s-%s' % (determine_ext(source['src']), source.get('height')), | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  |             'url': source['src'], | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |             'width': int_or_none(source.get('width')), | 
					
						
							|  |  |  |             'height': int_or_none(source.get('height')), | 
					
						
							|  |  |  |             'tbr': int_or_none(source.get('bitrate')), | 
					
						
							|  |  |  |         } for source in video_data['sources']] | 
					
						
							|  |  |  |         self._sort_formats(formats) | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # For both metadata and downloaded files the duration varies among | 
					
						
							|  |  |  |         # formats. I just pick the max one | 
					
						
							|  |  |  |         duration = max(filter(None, [ | 
					
						
							|  |  |  |             float_or_none(source.get('duration'), scale=1000) | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |             for source in video_data['sources']])) | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         subtitles = {} | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |         for translation in video_data.get('translations', []): | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  |             lang_id = translation.get('language_w3c') or ISO639Utils.long2short(translation['language_medium']) | 
					
						
							|  |  |  |             if lang_id not in subtitles: | 
					
						
							|  |  |  |                 subtitles[lang_id] = [] | 
					
						
							|  |  |  |             subtitles[lang_id].append({ | 
					
						
							|  |  |  |                 'url': translation['vttPath'], | 
					
						
							|  |  |  |                 'ext': 'vtt', | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'formats': formats, | 
					
						
							| 
									
										
										
										
											2015-10-29 19:55:04 +01:00
										 |  |  |             'title': video_data['title'], | 
					
						
							|  |  |  |             'description': video_data.get('description'), | 
					
						
							|  |  |  |             'thumbnail': video_data['video'].get('poster'), | 
					
						
							| 
									
										
										
										
											2015-06-21 18:55:26 +08:00
										 |  |  |             'duration': duration, | 
					
						
							|  |  |  |             'subtitles': subtitles, | 
					
						
							|  |  |  |         } |