| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | # coding: utf-8 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     determine_ext, | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |     extract_attributes, | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FranceCultureIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P<id>[^/?#&]+)' | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |         'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks', | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |             'id': 'rendez-vous-au-pays-des-geeks', | 
					
						
							|  |  |  |             'display_id': 'rendez-vous-au-pays-des-geeks', | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'ext': 'mp3', | 
					
						
							|  |  |  |             'title': 'Rendez-vous au pays des geeks', | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |             'thumbnail': r're:^https?://.*\.jpg$', | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'upload_date': '20140301', | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             'timestamp': 1393642916, | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |             'vcodec': 'none', | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         display_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |         webpage = self._download_webpage(url, display_id) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |         video_data = extract_attributes(self._search_regex( | 
					
						
							|  |  |  |             r'(?s)<div[^>]+class="[^"]*?(?:title-zone-diffusion|heading-zone-(?:wrapper|player-button))[^"]*?"[^>]*>.*?(<button[^>]+data-asset-source="[^"]+"[^>]+>)', | 
					
						
							|  |  |  |             webpage, 'video data')) | 
					
						
							| 
									
										
										
										
											2015-12-27 15:30:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |         video_url = video_data['data-asset-source'] | 
					
						
							|  |  |  |         title = video_data.get('data-asset-title') or self._og_search_title(webpage) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |         description = self._html_search_regex( | 
					
						
							|  |  |  |             r'(?s)<div[^>]+class="intro"[^>]*>.*?<h2>(.+?)</h2>', | 
					
						
							|  |  |  |             webpage, 'description', default=None) | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |         thumbnail = self._search_regex( | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+(?:data-dejavu-)?src="([^"]+)"', | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |             webpage, 'thumbnail', fatal=False) | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |         uploader = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             r'(?s)<span class="author">(.*?)</span>', | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             webpage, 'uploader', default=None) | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |         ext = determine_ext(video_url.lower()) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |             'id': display_id, | 
					
						
							|  |  |  |             'display_id': display_id, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'title': title, | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             'description': description, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'thumbnail': thumbnail, | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             'ext': ext, | 
					
						
							|  |  |  |             'vcodec': 'none' if ext == 'mp3' else None, | 
					
						
							| 
									
										
										
										
											2016-08-13 21:00:34 +07:00
										 |  |  |             'uploader': uploader, | 
					
						
							| 
									
										
										
										
											2017-03-25 07:03:13 +01:00
										 |  |  |             'timestamp': int_or_none(video_data.get('data-asset-created-date')), | 
					
						
							|  |  |  |             'duration': int_or_none(video_data.get('data-duration')), | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         } |