4a07b555838767b18e11cc686dd178d95e537883
[youtube-dl] / youtube_dl / extractor / goldenmoustache.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5     int_or_none,
6 )
7
8
9 class GoldenMoustacheIE(InfoExtractor):
10     _VALID_URL = r'https?://(?:www\.)?goldenmoustache\.com/(?P<display_id>[\w-]+)-(?P<id>\d+)'
11     _TESTS = [{
12         'url': 'http://www.goldenmoustache.com/suricate-le-poker-3700/',
13         'md5': '0f904432fa07da5054d6c8beb5efb51a',
14         'info_dict': {
15             'id': '3700',
16             'ext': 'mp4',
17             'title': 'Suricate - Le Poker',
18             'description': 'md5:3d1f242f44f8c8cb0a106f1fd08e5dc9',
19             'thumbnail': 're:^https?://.*\.jpg$',
20         }
21     }, {
22         'url': 'http://www.goldenmoustache.com/le-lab-tout-effacer-mc-fly-et-carlito-55249/',
23         'md5': '27f0c50fb4dd5f01dc9082fc67cd5700',
24         'info_dict': {
25             'id': '55249',
26             'ext': 'mp4',
27             'title': 'Le LAB - Tout Effacer (Mc Fly et Carlito)',
28             'description': 'md5:9b7fbf11023fb2250bd4b185e3de3b2a',
29             'thumbnail': 're:^https?://.*\.(?:png|jpg)$',
30         }
31     }]
32
33     def _real_extract(self, url):
34         video_id = self._match_id(url)
35         webpage = self._download_webpage(url, video_id)
36
37         video_url = self._html_search_regex(
38             r'data-src-type="mp4" data-src="([^"]+)"', webpage, 'video URL')
39         title = self._html_search_regex(
40             r'<title>(.*?)(?: - Golden Moustache)?</title>', webpage, 'title')
41         thumbnail = self._og_search_thumbnail(webpage)
42         description = self._og_search_description(webpage)
43
44         return {
45             'id': video_id,
46             'url': video_url,
47             'ext': 'mp4',
48             'title': title,
49             'description': description,
50             'thumbnail': thumbnail,
51         }