Merge remote-tracking branch 'hojel/nuvid'
[youtube-dl] / youtube_dl / extractor / nuvid.py
1 import re
2
3 from .common import InfoExtractor
4
5 class NuvidIE(InfoExtractor):
6     _VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<videoid>\d+)'
7     _TEST = {
8         u'url': u'http://m.nuvid.com/video/1310741/',
9         u'file': u'1310741.mp4',
10         u'md5': u'eab207b7ac4fccfb4e23c86201f11277',
11         u'info_dict': {
12             u"title": u"Horny babes show their awesome bodeis and",
13             u"age_limit": 18,
14         }
15     }
16
17     def _real_extract(self, url):
18         mobj = re.match(self._VALID_URL, url)
19
20         video_id = mobj.group('videoid')
21
22         # Get webpage content
23         murl = url.replace('//www.', '//m.')
24         webpage = self._download_webpage(murl, video_id)
25
26         video_title = self._html_search_regex(r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>', webpage, 'video_title').strip()
27
28         video_url = 'http://m.nuvid.com'+self._html_search_regex(r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"', webpage, 'video_url')
29
30         video_thumb = self._html_search_regex(r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"', webpage, 'video_thumb')
31
32         info = {'id': video_id,
33                 'url': video_url,
34                 'title': video_title,
35                 'thumbnail': video_thumb,
36                 'ext': 'mp4',
37                 'age_limit': 18}
38
39         return [info]