]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/goldenmoustache.py
Fix lintian warning introduced by Ben's patch.
[youtubedl] / 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 'view_count': int,
21 }
22 }, {
23 'url': 'http://www.goldenmoustache.com/le-lab-tout-effacer-mc-fly-et-carlito-55249/',
24 'md5': '27f0c50fb4dd5f01dc9082fc67cd5700',
25 'info_dict': {
26 'id': '55249',
27 'ext': 'mp4',
28 'title': 'Le LAB - Tout Effacer (Mc Fly et Carlito)',
29 'description': 'md5:9b7fbf11023fb2250bd4b185e3de3b2a',
30 'thumbnail': 're:^https?://.*\.(?:png|jpg)$',
31 'view_count': int,
32 }
33 }]
34
35 def _real_extract(self, url):
36 video_id = self._match_id(url)
37 webpage = self._download_webpage(url, video_id)
38
39 video_url = self._html_search_regex(
40 r'data-src-type="mp4" data-src="([^"]+)"', webpage, 'video URL')
41 title = self._html_search_regex(
42 r'<title>(.*?)(?: - Golden Moustache)?</title>', webpage, 'title')
43 thumbnail = self._og_search_thumbnail(webpage)
44 description = self._og_search_description(webpage)
45 view_count = int_or_none(self._html_search_regex(
46 r'<strong>([0-9]+)</strong>\s*VUES</span>',
47 webpage, 'view count', fatal=False))
48
49 return {
50 'id': video_id,
51 'url': video_url,
52 'ext': 'mp4',
53 'title': title,
54 'description': description,
55 'thumbnail': thumbnail,
56 'view_count': view_count,
57 }