Merge remote-tracking branch 'rzhxeo/crunchyroll'
[youtube-dl] / youtube_dl / extractor / wimp.py
1 import re
2 import base64
3
4 from .common import InfoExtractor
5
6
7 class WimpIE(InfoExtractor):
8     _VALID_URL = r'(?:http://)?(?:www\.)?wimp\.com/([^/]+)/'
9     _TEST = {
10         u'url': u'http://www.wimp.com/deerfence/',
11         u'file': u'deerfence.flv',
12         u'md5': u'8b215e2e0168c6081a1cf84b2846a2b5',
13         u'info_dict': {
14             u"title": u"Watch Till End: Herd of deer jump over a fence.",
15             u"description": u"These deer look as fluid as running water when they jump over this fence as a herd. This video is one that needs to be watched until the very end for the true majesty to be witnessed, but once it comes, it's sure to take your breath away.",
16         }
17     }
18
19     def _real_extract(self, url):
20         mobj = re.match(self._VALID_URL, url)
21         video_id = mobj.group(1)
22         webpage = self._download_webpage(url, video_id)
23         googleString = self._search_regex("googleCode = '(.*?)'", webpage, 'file url')
24         googleString = base64.b64decode(googleString).decode('ascii')
25         final_url = self._search_regex('","(.*?)"', googleString, u'final video url')
26
27         return {
28             'id': video_id,
29             'url': final_url,
30             'title': self._og_search_title(webpage),
31             'thumbnail': self._og_search_thumbnail(webpage),
32             'description': self._og_search_description(webpage),
33         }