1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[xnxx] Fix extraction (closes #15817)

This commit is contained in:
Sergey M․ 2018-03-10 23:13:14 +07:00
parent cc7f6c720e
commit b4a190fe2a
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1,19 +1,29 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_urllib_parse_unquote from ..utils import (
determine_ext,
int_or_none,
NO_DEFAULT,
str_to_int,
)
class XNXXIE(InfoExtractor): class XNXXIE(InfoExtractor):
_VALID_URL = r'https?://(?:video|www)\.xnxx\.com/video-?(?P<id>[0-9a-z]+)/' _VALID_URL = r'https?://(?:video|www)\.xnxx\.com/video-?(?P<id>[0-9a-z]+)/'
_TESTS = [{ _TESTS = [{
'url': 'http://www.xnxx.com/video-55awb78/skyrim_test_video', 'url': 'http://www.xnxx.com/video-55awb78/skyrim_test_video',
'md5': 'ef7ecee5af78f8b03dca2cf31341d3a0', 'md5': '7583e96c15c0f21e9da3453d9920fbba',
'info_dict': { 'info_dict': {
'id': '55awb78', 'id': '55awb78',
'ext': 'flv', 'ext': 'mp4',
'title': 'Skyrim Test Video', 'title': 'Skyrim Test Video',
'thumbnail': r're:^https?://.*\.jpg',
'duration': 469,
'view_count': int,
'age_limit': 18, 'age_limit': 18,
}, },
}, { }, {
@ -26,23 +36,49 @@ class XNXXIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_url = self._search_regex(r'flv_url=(.*?)&amp;', def get(meta, default=NO_DEFAULT, fatal=True):
webpage, 'video URL') return self._search_regex(
video_url = compat_urllib_parse_unquote(video_url) r'set%s\s*\(\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % meta,
webpage, meta, default=default, fatal=fatal, group='value')
video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XNXX.COM', title = self._og_search_title(
webpage, 'title') webpage, default=None) or get('VideoTitle')
video_thumbnail = self._search_regex(r'url_bigthumb=(.*?)&amp;', formats = []
webpage, 'thumbnail', fatal=False) for mobj in re.finditer(
r'setVideo(?:Url(?P<id>Low|High)|HLS)\s*\(\s*(?P<q>["\'])(?P<url>(?:https?:)?//.+?)(?P=q)', webpage):
format_url = mobj.group('url')
if determine_ext(format_url) == 'm3u8':
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4', entry_protocol='m3u8_native',
preference=1, m3u8_id='hls', fatal=False))
else:
format_id = mobj.group('id')
if format_id:
format_id = format_id.lower()
formats.append({
'url': format_url,
'format_id': format_id,
'quality': -1 if format_id == 'low' else 0,
})
self._sort_formats(formats)
thumbnail = self._og_search_thumbnail(webpage, default=None) or get(
'ThumbUrl', fatal=False) or get('ThumbUrl169', fatal=False)
duration = int_or_none(self._og_search_property('duration', webpage))
view_count = str_to_int(self._search_regex(
r'id=["\']nb-views-number[^>]+>([\d,.]+)', webpage, 'view count',
default=None))
return { return {
'id': video_id, 'id': video_id,
'url': video_url, 'title': title,
'title': video_title, 'thumbnail': thumbnail,
'ext': 'flv', 'duration': duration,
'thumbnail': video_thumbnail, 'view_count': view_count,
'age_limit': 18, 'age_limit': 18,
'formats': formats,
} }