| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  | # coding: utf-8 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  | from .brightcove import BrightcoveNewIE | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | from ..compat import compat_str | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |     js_to_json, | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |     smuggle_url, | 
					
						
							|  |  |  |     try_get, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NoovoIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |     _VALID_URL = r'https?://(?:[^/]+\.)?noovo\.ca/videos/(?P<id>[^/]+/[^/?#&]+)' | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |         # clip | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |         'url': 'http://noovo.ca/videos/rpm-plus/chrysler-imperial', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '5386045029001', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Chrysler Imperial', | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'description': 'md5:de3c898d1eb810f3e6243e08c8b4a056', | 
					
						
							|  |  |  |             'timestamp': 1491399228, | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |             'upload_date': '20170405', | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'uploader_id': '618566855001', | 
					
						
							|  |  |  |             'series': 'RPM+', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							|  |  |  |             'skip_download': True, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |     }, { | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |         # episode | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |         'url': 'http://noovo.ca/videos/l-amour-est-dans-le-pre/episode-13-8', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '5395865725001', | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'title': 'Épisode 13 : Les retrouvailles', | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |             'description': 'md5:888c3330f0c1b4476c5bc99a1c040473', | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'timestamp': 1492019320, | 
					
						
							|  |  |  |             'upload_date': '20170412', | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'uploader_id': '618566855001', | 
					
						
							|  |  |  |             'series': "L'amour est dans le pré", | 
					
						
							|  |  |  |             'season_number': 5, | 
					
						
							|  |  |  |             'episode': 'Épisode 13', | 
					
						
							|  |  |  |             'episode_number': 13, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'params': { | 
					
						
							|  |  |  |             'skip_download': True, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  |     }] | 
					
						
							|  |  |  |     BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/618566855001/default_default/index.html?videoId=%s' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         video_id = self._match_id(url) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							| 
									
										
										
										
											2017-04-19 17:43:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |         bc_url = BrightcoveNewIE._extract_url(self, webpage) | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |         data = self._parse_json( | 
					
						
							|  |  |  |             self._search_regex( | 
					
						
							|  |  |  |                 r'(?s)dataLayer\.push\(\s*({.+?})\s*\);', webpage, 'data', | 
					
						
							|  |  |  |                 default='{}'), | 
					
						
							|  |  |  |             video_id, transform_source=js_to_json, fatal=False) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         title = try_get( | 
					
						
							|  |  |  |             data, lambda x: x['video']['nom'], | 
					
						
							|  |  |  |             compat_str) or self._html_search_meta( | 
					
						
							|  |  |  |             'dcterms.Title', webpage, 'title', fatal=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         description = self._html_search_meta( | 
					
						
							|  |  |  |             ('dcterms.Description', 'description'), webpage, 'description') | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         series = try_get( | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |             data, lambda x: x['emission']['nom']) or self._search_regex( | 
					
						
							|  |  |  |             r'<div[^>]+class="banner-card__subtitle h4"[^>]*>([^<]+)', | 
					
						
							|  |  |  |             webpage, 'series', default=None) | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |         season_el = try_get(data, lambda x: x['emission']['saison'], dict) or {} | 
					
						
							|  |  |  |         season = try_get(season_el, lambda x: x['nom'], compat_str) | 
					
						
							|  |  |  |         season_number = int_or_none(try_get(season_el, lambda x: x['numero'])) | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |         episode_el = try_get(season_el, lambda x: x['episode'], dict) or {} | 
					
						
							|  |  |  |         episode = try_get(episode_el, lambda x: x['nom'], compat_str) | 
					
						
							|  |  |  |         episode_number = int_or_none(try_get(episode_el, lambda x: x['numero'])) | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             '_type': 'url_transparent', | 
					
						
							|  |  |  |             'ie_key': BrightcoveNewIE.ie_key(), | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |             'url': smuggle_url(bc_url, {'geo_countries': ['CA']}), | 
					
						
							|  |  |  |             'title': title, | 
					
						
							|  |  |  |             'description': description, | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'series': series, | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |             'season': season, | 
					
						
							|  |  |  |             'season_number': season_number, | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |             'episode': episode, | 
					
						
							| 
									
										
										
										
											2017-09-15 23:12:19 +07:00
										 |  |  |             'episode_number': episode_number, | 
					
						
							| 
									
										
										
										
											2017-04-30 00:23:50 +07:00
										 |  |  |         } |