| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | # coding: utf-8 | 
					
						
							|  |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2014-12-13 12:24:42 +01:00
										 |  |  | from ..compat import ( | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |     compat_urlparse, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     determine_ext, | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FranceCultureIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/player/reecouter\?play=(?P<id>[0-9]+)' | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |     _TEST = { | 
					
						
							|  |  |  |         'url': 'http://www.franceculture.fr/player/reecouter?play=4795174', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '4795174', | 
					
						
							|  |  |  |             'ext': 'mp3', | 
					
						
							|  |  |  |             'title': 'Rendez-vous au pays des geeks', | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             'alt_title': 'Carnet nomade | 13-14', | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'vcodec': 'none', | 
					
						
							|  |  |  |             'upload_date': '20140301', | 
					
						
							|  |  |  |             'thumbnail': r're:^http://www\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$', | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             'description': 'startswith:Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche des « geeks », une enquête menée aux Etats', | 
					
						
							|  |  |  |             'timestamp': 1393700400, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         video_path = self._search_regex( | 
					
						
							|  |  |  |             r'<a id="player".*?href="([^"]+)"', webpage, 'video path') | 
					
						
							|  |  |  |         video_url = compat_urlparse.urljoin(url, video_path) | 
					
						
							|  |  |  |         timestamp = int_or_none(self._search_regex( | 
					
						
							|  |  |  |             r'<a id="player".*?data-date="([0-9]+)"', | 
					
						
							|  |  |  |             webpage, 'upload date', fatal=False)) | 
					
						
							|  |  |  |         thumbnail = self._search_regex( | 
					
						
							|  |  |  |             r'<a id="player".*?>\s+<img src="([^"]+)"', | 
					
						
							|  |  |  |             webpage, 'thumbnail', fatal=False) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         title = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             r'<span class="title-diffusion">(.*?)</span>', webpage, 'title') | 
					
						
							|  |  |  |         alt_title = self._html_search_regex( | 
					
						
							|  |  |  |             r'<span class="title">(.*?)</span>', | 
					
						
							|  |  |  |             webpage, 'alt_title', fatal=False) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |         description = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             r'<span class="description">(.*?)</span>', | 
					
						
							|  |  |  |             webpage, 'description', fatal=False) | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |         uploader = self._html_search_regex( | 
					
						
							|  |  |  |             r'(?s)<div id="emission".*?<span class="author">(.*?)</span>', | 
					
						
							|  |  |  |             webpage, 'uploader', default=None) | 
					
						
							|  |  |  |         vcodec = 'none' if determine_ext(video_url.lower()) == 'mp3' else None | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             'vcodec': vcodec, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'uploader': uploader, | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             'timestamp': timestamp, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'title': title, | 
					
						
							| 
									
										
										
										
											2015-02-03 10:15:05 +01:00
										 |  |  |             'alt_title': alt_title, | 
					
						
							| 
									
										
										
										
											2014-04-03 08:55:38 +02:00
										 |  |  |             'thumbnail': thumbnail, | 
					
						
							|  |  |  |             'description': description, | 
					
						
							|  |  |  |         } |