]>
Commit | Line | Data |
---|---|---|
87724af7 PH |
1 | from __future__ import unicode_literals |
2 | ||
749fe60c | 3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
3048e82a S |
6 | from ..utils import ( |
7 | parse_duration, | |
8 | unified_strdate, | |
9 | compat_urllib_request, | |
10 | ) | |
749fe60c | 11 | |
87724af7 | 12 | |
749fe60c | 13 | class NuvidIE(InfoExtractor): |
87724af7 | 14 | _VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)' |
749fe60c | 15 | _TEST = { |
87724af7 PH |
16 | 'url': 'http://m.nuvid.com/video/1310741/', |
17 | 'md5': 'eab207b7ac4fccfb4e23c86201f11277', | |
18 | 'info_dict': { | |
19 | 'id': '1310741', | |
20 | 'ext': 'mp4', | |
3048e82a S |
21 | 'title': 'Horny babes show their awesome bodeis and', |
22 | 'duration': 129, | |
23 | 'upload_date': '20140508', | |
24 | 'age_limit': 18, | |
749fe60c | 25 | } |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
29 | mobj = re.match(self._VALID_URL, url) | |
87724af7 | 30 | video_id = mobj.group('id') |
749fe60c | 31 | |
3048e82a | 32 | formats = [] |
87724af7 | 33 | |
3048e82a S |
34 | for dwnld_speed, format_id in [(0, '3gp'), (5, 'mp4')]: |
35 | request = compat_urllib_request.Request( | |
36 | 'http://m.nuvid.com/play/%s' % video_id) | |
37 | request.add_header('Cookie', 'skip_download_page=1; dwnld_speed=%d; adv_show=1' % dwnld_speed) | |
38 | webpage = self._download_webpage( | |
39 | request, video_id, 'Downloading %s page' % format_id) | |
40 | video_url = self._html_search_regex( | |
394df6d7 | 41 | r'<a\s+href="([^"]+)"\s+class="b_link">', webpage, '%s video URL' % format_id, fatal=False) |
3048e82a S |
42 | if not video_url: |
43 | continue | |
44 | formats.append({ | |
45 | 'url': video_url, | |
46 | 'format_id': format_id, | |
47 | }) | |
87724af7 | 48 | |
3048e82a S |
49 | webpage = self._download_webpage( |
50 | 'http://m.nuvid.com/video/%s' % video_id, video_id, 'Downloading video page') | |
51 | title = self._html_search_regex( | |
394df6d7 S |
52 | [r'<span title="([^"]+)">', |
53 | r'<div class="thumb-holder video">\s*<h5[^>]*>([^<]+)</h5>'], webpage, 'title').strip() | |
54 | thumbnails = [ | |
55 | { | |
56 | 'url': thumb_url, | |
57 | } for thumb_url in re.findall(r'<img src="([^"]+)" alt="" />', webpage) | |
58 | ] | |
59 | thumbnail = thumbnails[0]['url'] if thumbnails else None | |
3048e82a | 60 | duration = parse_duration(self._html_search_regex( |
394df6d7 | 61 | r'<i class="fa fa-clock-o"></i>\s*(\d{2}:\d{2})', webpage, 'duration', fatal=False)) |
3048e82a | 62 | upload_date = unified_strdate(self._html_search_regex( |
394df6d7 | 63 | r'<i class="fa fa-user"></i>\s*(\d{4}-\d{2}-\d{2})', webpage, 'upload date', fatal=False)) |
87724af7 PH |
64 | |
65 | return { | |
66 | 'id': video_id, | |
87724af7 | 67 | 'title': title, |
394df6d7 S |
68 | 'thumbnails': thumbnails, |
69 | 'thumbnail': thumbnail, | |
3048e82a S |
70 | 'duration': duration, |
71 | 'upload_date': upload_date, | |
87724af7 | 72 | 'age_limit': 18, |
3048e82a S |
73 | 'formats': formats, |
74 | } |