aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/extractor/nuvid.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-10-18 15:24:21 -0500
committerJesús <heckyel@hyperbola.info>2021-10-18 15:24:21 -0500
commit5122028a4bcac4ae577ef7fbd55ccad5cb34ef5e (patch)
tree65209bc739db35e31f1c9b5b868eb5df4fe12ae3 /hypervideo_dl/extractor/nuvid.py
parent27fe903c511691c078942bef5ee9a05a43b15c8f (diff)
downloadhypervideo-5122028a4bcac4ae577ef7fbd55ccad5cb34ef5e.tar.lz
hypervideo-5122028a4bcac4ae577ef7fbd55ccad5cb34ef5e.tar.xz
hypervideo-5122028a4bcac4ae577ef7fbd55ccad5cb34ef5e.zip
update from upstream
Diffstat (limited to 'hypervideo_dl/extractor/nuvid.py')
-rw-r--r--hypervideo_dl/extractor/nuvid.py86
1 files changed, 44 insertions, 42 deletions
diff --git a/hypervideo_dl/extractor/nuvid.py b/hypervideo_dl/extractor/nuvid.py
index ab6bfcd..7487824 100644
--- a/hypervideo_dl/extractor/nuvid.py
+++ b/hypervideo_dl/extractor/nuvid.py
@@ -1,71 +1,73 @@
+# coding: utf-8
from __future__ import unicode_literals
-import re
-
from .common import InfoExtractor
from ..utils import (
parse_duration,
+ int_or_none,
+ try_get,
)
class NuvidIE(InfoExtractor):
_VALID_URL = r'https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
- _TEST = {
- 'url': 'http://m.nuvid.com/video/1310741/',
- 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
+ _TESTS = [{
+ 'url': 'https://www.nuvid.com/video/6513023/italian-babe',
+ 'md5': '772d2f8288f3d3c5c45f7a41761c7844',
+ 'info_dict': {
+ 'id': '6513023',
+ 'ext': 'mp4',
+ 'title': 'italian babe',
+ 'duration': 321.0,
+ 'age_limit': 18,
+ }
+ }, {
+ 'url': 'https://m.nuvid.com/video/6523263',
'info_dict': {
- 'id': '1310741',
+ 'id': '6523263',
'ext': 'mp4',
- 'title': 'Horny babes show their awesome bodeis and',
- 'duration': 129,
'age_limit': 18,
+ 'title': 'Slut brunette college student anal dorm',
}
- }
+ }]
def _real_extract(self, url):
video_id = self._match_id(url)
- page_url = 'http://m.nuvid.com/video/%s' % video_id
- webpage = self._download_webpage(
- page_url, video_id, 'Downloading video page')
- # When dwnld_speed exists and has a value larger than the MP4 file's
- # bitrate, Nuvid returns the MP4 URL
- # It's unit is 100bytes/millisecond, see mobile-nuvid-min.js for the algorithm
- self._set_cookie('nuvid.com', 'dwnld_speed', '10.0')
- mp4_webpage = self._download_webpage(
- page_url, video_id, 'Downloading video page for MP4 format')
+ qualities = {
+ 'lq': '360p',
+ 'hq': '720p',
+ }
+
+ json_url = f'https://www.nuvid.com/player_config_json/?vid={video_id}&aid=0&domain_id=0&embed=0&check_speed=0'
+ video_data = self._download_json(
+ json_url, video_id, headers={
+ 'Accept': 'application/json, text/javascript, */*; q = 0.01',
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
+ })
- html5_video_re = r'(?s)<(?:video|audio)[^<]*(?:>.*?<source[^>]*)?\s+src=["\'](.*?)["\']',
- video_url = self._html_search_regex(html5_video_re, webpage, video_id)
- mp4_video_url = self._html_search_regex(html5_video_re, mp4_webpage, video_id)
formats = [{
- 'url': video_url,
- }]
- if mp4_video_url != video_url:
- formats.append({
- 'url': mp4_video_url,
- })
+ 'url': source,
+ 'format_id': qualities.get(quality),
+ 'height': int_or_none(qualities.get(quality)[:-1]),
+ } for quality, source in video_data.get('files').items() if source]
- title = self._html_search_regex(
- [r'<span title="([^"]+)">',
- r'<div class="thumb-holder video">\s*<h5[^>]*>([^<]+)</h5>',
- r'<span[^>]+class="title_thumb">([^<]+)</span>'], webpage, 'title').strip()
- thumbnails = [
- {
- 'url': thumb_url,
- } for thumb_url in re.findall(r'<img src="([^"]+)" alt="" />', webpage)
- ]
- thumbnail = thumbnails[0]['url'] if thumbnails else None
- duration = parse_duration(self._html_search_regex(
- [r'<i class="fa fa-clock-o"></i>\s*(\d{2}:\d{2})',
- r'<span[^>]+class="view_time">([^<]+)</span>'], webpage, 'duration', fatal=False))
+ self._check_formats(formats, video_id)
+ self._sort_formats(formats)
+
+ title = video_data.get('title')
+ thumbnail_base_url = try_get(video_data, lambda x: x['thumbs']['url'])
+ thumbnail_extension = try_get(video_data, lambda x: x['thumbs']['extension'])
+ thumbnail_id = self._search_regex(
+ r'/media/videos/tmb/6523263/preview/(/d+)' + thumbnail_extension, video_data.get('poster', ''), 'thumbnail id', default=19)
+ thumbnail = f'{thumbnail_base_url}player/{thumbnail_id}{thumbnail_extension}'
+ duration = parse_duration(video_data.get('duration') or video_data.get('duration_format'))
return {
'id': video_id,
+ 'formats': formats,
'title': title,
- 'thumbnails': thumbnails,
'thumbnail': thumbnail,
'duration': duration,
'age_limit': 18,
- 'formats': formats,
}