aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-05-13 10:08:32 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-05-13 10:08:32 +0200
commit87724af7a8a22d00199fbda75c5b99f336386fca (patch)
tree2ccb49bcd0f396495171f7edf355c14f177f9cdd /youtube_dl/extractor
parentb65c3e77e8fa893a41eb058102422f42276ebc11 (diff)
[nuvid] Simplify (#2901)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/nuvid.py59
1 files changed, 34 insertions, 25 deletions
diff --git a/youtube_dl/extractor/nuvid.py b/youtube_dl/extractor/nuvid.py
index 2e5198c1a..f0befa116 100644
--- a/youtube_dl/extractor/nuvid.py
+++ b/youtube_dl/extractor/nuvid.py
@@ -1,39 +1,48 @@
+from __future__ import unicode_literals
+
import re
from .common import 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 = {
- u'url': u'http://m.nuvid.com/video/1310741/',
- u'file': u'1310741.mp4',
- u'md5': u'eab207b7ac4fccfb4e23c86201f11277',
- u'info_dict': {
- u"title": u"Horny babes show their awesome bodeis and",
- u"age_limit": 18,
+ 'url': 'http://m.nuvid.com/video/1310741/',
+ 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
+ 'info_dict': {
+ 'id': '1310741',
+ 'ext': 'mp4',
+ "title": "Horny babes show their awesome bodeis and",
+ "age_limit": 18,
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
- video_id = mobj.group('videoid')
-
- # Get webpage content
- murl = url.replace('//www.', '//m.')
+ murl = url.replace('://www.', '://m.')
webpage = self._download_webpage(murl, video_id)
- video_title = self._html_search_regex(r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>', webpage, 'video_title').strip()
-
- video_url = 'http://m.nuvid.com'+self._html_search_regex(r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"', webpage, 'video_url')
-
- video_thumb = self._html_search_regex(r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"', webpage, 'video_thumb')
-
- info = {'id': video_id,
- 'url': video_url,
- 'title': video_title,
- 'thumbnail': video_thumb,
- 'ext': 'mp4',
- 'age_limit': 18}
-
- return [info]
+ title = self._html_search_regex(
+ r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>',
+ webpage, 'title').strip()
+
+ url_end = self._html_search_regex(
+ r'href="(/mp4/[^"]+)"[^>]*data-link_type="mp4"',
+ webpage, 'video_url')
+ video_url = 'http://m.nuvid.com' + url_end
+
+ thumbnail = self._html_search_regex(
+ r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"',
+ webpage, 'thumbnail URL', fatal=False)
+
+ return {
+ 'id': video_id,
+ 'url': video_url,
+ 'ext': 'mp4',
+ 'title': title,
+ 'thumbnail': thumbnail,
+ 'age_limit': 18,
+ }