[nuvid] Simplify (#2901)

pull/2923/head
Philipp Hagemeister 11 years ago
parent b65c3e77e8
commit 87724af7a8

@ -1,39 +1,48 @@
from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
class NuvidIE(InfoExtractor): class NuvidIE(InfoExtractor):
_VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<videoid>\d+)' _VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
_TEST = { _TEST = {
u'url': u'http://m.nuvid.com/video/1310741/', 'url': 'http://m.nuvid.com/video/1310741/',
u'file': u'1310741.mp4', 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
u'md5': u'eab207b7ac4fccfb4e23c86201f11277', 'info_dict': {
u'info_dict': { 'id': '1310741',
u"title": u"Horny babes show their awesome bodeis and", 'ext': 'mp4',
u"age_limit": 18, "title": "Horny babes show their awesome bodeis and",
"age_limit": 18,
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
video_id = mobj.group('videoid') murl = url.replace('://www.', '://m.')
# Get webpage content
murl = url.replace('//www.', '//m.')
webpage = self._download_webpage(murl, video_id) webpage = self._download_webpage(murl, video_id)
video_title = self._html_search_regex(r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>', webpage, 'video_title').strip() title = self._html_search_regex(
r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>',
webpage, 'title').strip()
video_url = 'http://m.nuvid.com'+self._html_search_regex(r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"', webpage, 'video_url') url_end = self._html_search_regex(
r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"',
webpage, 'video_url')
video_url = 'http://m.nuvid.com' + url_end
video_thumb = self._html_search_regex(r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"', webpage, 'video_thumb') thumbnail = self._html_search_regex(
r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"',
webpage, 'thumbnail URL', fatal=False)
info = {'id': video_id, return {
'id': video_id,
'url': video_url, 'url': video_url,
'title': video_title,
'thumbnail': video_thumb,
'ext': 'mp4', 'ext': 'mp4',
'age_limit': 18} 'title': title,
'thumbnail': thumbnail,
return [info] 'age_limit': 18,
}

Loading…
Cancel
Save