]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/nuvid.py
[nuvid] Simplify (#2901)
[yt-dlp.git] / youtube_dl / extractor / nuvid.py
CommitLineData
87724af7
PH
1from __future__ import unicode_literals
2
749fe60c 3import re
4
5from .common import InfoExtractor
6
87724af7 7
749fe60c 8class NuvidIE(InfoExtractor):
87724af7 9 _VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
749fe60c 10 _TEST = {
87724af7
PH
11 'url': 'http://m.nuvid.com/video/1310741/',
12 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
13 'info_dict': {
14 'id': '1310741',
15 'ext': 'mp4',
16 "title": "Horny babes show their awesome bodeis and",
17 "age_limit": 18,
749fe60c 18 }
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
87724af7 23 video_id = mobj.group('id')
749fe60c 24
87724af7 25 murl = url.replace('://www.', '://m.')
749fe60c 26 webpage = self._download_webpage(murl, video_id)
27
87724af7
PH
28 title = self._html_search_regex(
29 r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>',
30 webpage, 'title').strip()
31
32 url_end = self._html_search_regex(
33 r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"',
34 webpage, 'video_url')
35 video_url = 'http://m.nuvid.com' + url_end
36
37 thumbnail = self._html_search_regex(
38 r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"',
39 webpage, 'thumbnail URL', fatal=False)
40
41 return {
42 'id': video_id,
43 'url': video_url,
44 'ext': 'mp4',
45 'title': title,
46 'thumbnail': thumbnail,
47 'age_limit': 18,
48 }