| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GoldenMoustacheIE(InfoExtractor): | 
					
						
							|  |  |  |     _VALID_URL = r'https?://(?:www\.)?goldenmoustache\.com/(?P<display_id>[\w-]+)-(?P<id>\d+)' | 
					
						
							| 
									
										
										
										
											2014-11-15 15:21:34 +01:00
										 |  |  |     _TESTS = [{ | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  |         'url': 'http://www.goldenmoustache.com/suricate-le-poker-3700/', | 
					
						
							|  |  |  |         'md5': '0f904432fa07da5054d6c8beb5efb51a', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '3700', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Suricate - Le Poker', | 
					
						
							|  |  |  |             'description': 'md5:3d1f242f44f8c8cb0a106f1fd08e5dc9', | 
					
						
							| 
									
										
										
										
											2014-11-12 15:36:59 +01:00
										 |  |  |             'thumbnail': 're:^https?://.*\.jpg$', | 
					
						
							|  |  |  |             'view_count': int, | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-11-15 15:21:34 +01:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'http://www.goldenmoustache.com/le-lab-tout-effacer-mc-fly-et-carlito-55249/', | 
					
						
							|  |  |  |         'md5': '27f0c50fb4dd5f01dc9082fc67cd5700', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '55249', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Le LAB - Tout Effacer (Mc Fly et Carlito)', | 
					
						
							|  |  |  |             'description': 'md5:9b7fbf11023fb2250bd4b185e3de3b2a', | 
					
						
							|  |  |  |             'thumbnail': 're:^https?://.*\.(?:png|jpg)$', | 
					
						
							|  |  |  |             'view_count': int, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }] | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2014-11-12 15:36:59 +01:00
										 |  |  |         video_id = self._match_id(url) | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  |         webpage = self._download_webpage(url, video_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 15:36:59 +01:00
										 |  |  |         video_url = self._html_search_regex( | 
					
						
							|  |  |  |             r'data-src-type="mp4" data-src="([^"]+)"', webpage, 'video URL') | 
					
						
							|  |  |  |         title = self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2014-11-15 15:21:34 +01:00
										 |  |  |             r'<title>(.*?)(?: - Golden Moustache)?</title>', webpage, 'title') | 
					
						
							| 
									
										
										
										
											2014-11-12 15:36:59 +01:00
										 |  |  |         thumbnail = self._og_search_thumbnail(webpage) | 
					
						
							|  |  |  |         description = self._og_search_description(webpage) | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  |         view_count = int_or_none(self._html_search_regex( | 
					
						
							| 
									
										
										
										
											2014-11-12 15:36:59 +01:00
										 |  |  |             r'<strong>([0-9]+)</strong>\s*VUES</span>', | 
					
						
							|  |  |  |             webpage, 'view count', fatal=False)) | 
					
						
							| 
									
										
										
										
											2014-11-07 17:44:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': title, | 
					
						
							|  |  |  |             'description': description, | 
					
						
							|  |  |  |             'thumbnail': thumbnail, | 
					
						
							|  |  |  |             'view_count': view_count, | 
					
						
							|  |  |  |         } |