2021-09-19 06:26:29 -06:00
|
|
|
# coding: utf-8
|
2014-05-13 02:08:32 -06:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-05-12 04:48:40 -06:00
|
|
|
from .common import InfoExtractor
|
2014-06-09 07:37:04 -06:00
|
|
|
from ..utils import (
|
|
|
|
parse_duration,
|
2021-09-19 06:26:29 -06:00
|
|
|
int_or_none,
|
|
|
|
try_get,
|
2014-06-09 07:37:04 -06:00
|
|
|
)
|
2014-05-12 04:48:40 -06:00
|
|
|
|
2014-05-13 02:08:32 -06:00
|
|
|
|
2014-05-12 04:48:40 -06:00
|
|
|
class NuvidIE(InfoExtractor):
|
2014-12-13 04:24:42 -07:00
|
|
|
_VALID_URL = r'https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
|
2021-09-19 06:26:29 -06:00
|
|
|
_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',
|
2014-05-13 02:08:32 -06:00
|
|
|
'info_dict': {
|
2021-09-19 06:26:29 -06:00
|
|
|
'id': '6523263',
|
2014-05-13 02:08:32 -06:00
|
|
|
'ext': 'mp4',
|
2014-06-09 07:37:04 -06:00
|
|
|
'age_limit': 18,
|
2021-09-19 06:26:29 -06:00
|
|
|
'title': 'Slut brunette college student anal dorm',
|
2014-05-12 04:48:40 -06:00
|
|
|
}
|
2021-09-19 06:26:29 -06:00
|
|
|
}]
|
2014-05-12 04:48:40 -06:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-13 04:24:42 -07:00
|
|
|
video_id = self._match_id(url)
|
2014-05-12 04:48:40 -06:00
|
|
|
|
2021-09-19 06:26:29 -06:00
|
|
|
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',
|
|
|
|
})
|
2014-05-13 02:08:32 -06:00
|
|
|
|
2016-04-28 03:51:20 -06:00
|
|
|
formats = [{
|
2021-09-19 06:26:29 -06:00
|
|
|
'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]
|
2014-05-13 02:08:32 -06:00
|
|
|
|
2021-09-19 06:26:29 -06:00
|
|
|
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'))
|
2014-05-13 02:08:32 -06:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2021-09-19 06:26:29 -06:00
|
|
|
'formats': formats,
|
2014-05-13 02:08:32 -06:00
|
|
|
'title': title,
|
2014-08-22 08:41:51 -06:00
|
|
|
'thumbnail': thumbnail,
|
2014-06-09 07:37:04 -06:00
|
|
|
'duration': duration,
|
2014-05-13 02:08:32 -06:00
|
|
|
'age_limit': 18,
|
2014-11-23 12:41:03 -07:00
|
|
|
}
|