]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wimp.py
Merge tag 'upstream/2014.07.11'
[youtubedl] / youtube_dl / extractor / wimp.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from .youtube import YoutubeIE
7
8
9 class WimpIE(InfoExtractor):
10 _VALID_URL = r'http://(?:www\.)?wimp\.com/([^/]+)/'
11 _TESTS = [{
12 'url': 'http://www.wimp.com/maruexhausted/',
13 'md5': 'f1acced123ecb28d9bb79f2479f2b6a1',
14 'info_dict': {
15 'id': 'maruexhausted',
16 'ext': 'flv',
17 'title': 'Maru is exhausted.',
18 'description': 'md5:57e099e857c0a4ea312542b684a869b8',
19 }
20 }, {
21 # youtube video
22 'url': 'http://www.wimp.com/clowncar/',
23 'info_dict': {
24 'id': 'cG4CEr2aiSg',
25 'ext': 'mp4',
26 'title': 'Basset hound clown car...incredible!',
27 'description': 'md5:8d228485e0719898c017203f900b3a35',
28 'uploader': 'Gretchen Hoey',
29 'uploader_id': 'gretchenandjeff1',
30 'upload_date': '20140303',
31 },
32 'add_ie': ['Youtube'],
33 }]
34
35 def _real_extract(self, url):
36 mobj = re.match(self._VALID_URL, url)
37 video_id = mobj.group(1)
38 webpage = self._download_webpage(url, video_id)
39 video_url = self._search_regex(
40 r's1\.addVariable\("file",\s*"([^"]+)"\);', webpage, 'video URL')
41 if YoutubeIE.suitable(video_url):
42 self.to_screen('Found YouTube video')
43 return {
44 '_type': 'url',
45 'url': video_url,
46 'ie_key': YoutubeIE.ie_key(),
47 }
48
49 return {
50 'id': video_id,
51 'url': video_url,
52 'title': self._og_search_title(webpage),
53 'thumbnail': self._og_search_thumbnail(webpage),
54 'description': self._og_search_description(webpage),
55 }