]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wimp.py
041ff6c555123d44c97bc63810d2aa7903ec069e
[youtubedl] / youtube_dl / extractor / wimp.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from .youtube import YoutubeIE
5
6
7 class WimpIE(InfoExtractor):
8 _VALID_URL = r'http://(?:www\.)?wimp\.com/(?P<id>[^/]+)'
9 _TESTS = [{
10 'url': 'http://www.wimp.com/maruexhausted/',
11 'md5': 'ee21217ffd66d058e8b16be340b74883',
12 'info_dict': {
13 'id': 'maruexhausted',
14 'ext': 'mp4',
15 'title': 'Maru is exhausted.',
16 'description': 'md5:57e099e857c0a4ea312542b684a869b8',
17 }
18 }, {
19 'url': 'http://www.wimp.com/clowncar/',
20 'md5': '4e2986c793694b55b37cf92521d12bb4',
21 'info_dict': {
22 'id': 'clowncar',
23 'ext': 'mp4',
24 'title': 'It\'s like a clown car.',
25 'description': 'md5:0e56db1370a6e49c5c1d19124c0d2fb2',
26 },
27 }]
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31
32 webpage = self._download_webpage(url, video_id)
33
34 youtube_id = self._search_regex(
35 r"videoId\s*:\s*[\"']([0-9A-Za-z_-]{11})[\"']",
36 webpage, 'video URL', default=None)
37 if youtube_id:
38 return {
39 '_type': 'url',
40 'url': youtube_id,
41 'ie_key': YoutubeIE.ie_key(),
42 }
43
44 video_url = self._search_regex(
45 r'<video[^>]+>\s*<source[^>]+src=(["\'])(?P<url>.+?)\1',
46 webpage, 'video URL', group='url')
47
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': self._og_search_title(webpage),
52 'thumbnail': self._og_search_thumbnail(webpage),
53 'description': self._og_search_description(webpage),
54 }