]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wimp.py
Update changelog.
[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"[\"']file[\"']\s*[:,]\s*[\"'](.+?)[\"']", r"videoId\s*:\s*[\"']([^\"']+)[\"']"],
41 webpage, 'video URL')
42 if YoutubeIE.suitable(video_url):
43 self.to_screen('Found YouTube video')
44 return {
45 '_type': 'url',
46 'url': video_url,
47 'ie_key': YoutubeIE.ie_key(),
48 }
49
50 return {
51 'id': video_id,
52 'url': video_url,
53 'title': self._og_search_title(webpage),
54 'thumbnail': self._og_search_thumbnail(webpage),
55 'description': self._og_search_description(webpage),
56 }