mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 09:12:40 +01:00
parent
82fb2357d9
commit
a79bf78397
@ -1,3 +1,5 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
@ -7,6 +9,7 @@
|
|||||||
parse_duration,
|
parse_duration,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
url_basename,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,9 +21,6 @@ class TNAFlixNetworkBaseIE(InfoExtractor):
|
|||||||
r'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"',
|
r'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"',
|
||||||
r'config\s*=\s*(["\'])(?P<url>(?:https?:)?//(?:(?!\1).)+)\1',
|
r'config\s*=\s*(["\'])(?P<url>(?:https?:)?//(?:(?!\1).)+)\1',
|
||||||
]
|
]
|
||||||
_HOST = 'tna'
|
|
||||||
_VIDEO_XML_URL = 'https://www.tnaflix.com/cdn/cdn.php?file={}.fid&key={}&VID={}&nomp4=1&catID=0&rollover=1&startThumb=12&embed=0&utm_source=0&multiview=0&premium=1&country=0user=0&vip=1&cd=0&ref=0&alpha'
|
|
||||||
_VKEY_SUFFIX = ''
|
|
||||||
_TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"'
|
_TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"'
|
||||||
_DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"'
|
_DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"'
|
||||||
_UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"'
|
_UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"'
|
||||||
@ -71,11 +71,7 @@ def get_child(elem, names):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = self._match_valid_url(url)
|
mobj = self._match_valid_url(url)
|
||||||
video_id = mobj.group('id')
|
video_id, host = mobj.group('id', 'host')
|
||||||
|
|
||||||
def extract_field(pattern, name):
|
|
||||||
return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
|
|
||||||
|
|
||||||
for display_id_key in ('display_id', 'display_id_2'):
|
for display_id_key in ('display_id', 'display_id_2'):
|
||||||
if display_id_key in mobj.groupdict():
|
if display_id_key in mobj.groupdict():
|
||||||
display_id = mobj.group(display_id_key)
|
display_id = mobj.group(display_id_key)
|
||||||
@ -86,27 +82,33 @@ def extract_field(pattern, name):
|
|||||||
|
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
|
# check for MovieFap-style config
|
||||||
cfg_url = self._proto_relative_url(self._html_search_regex(
|
cfg_url = self._proto_relative_url(self._html_search_regex(
|
||||||
self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
|
self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
|
||||||
group='url'), 'http:')
|
group='url'), 'http:')
|
||||||
|
query = {}
|
||||||
|
|
||||||
if not cfg_url:
|
# check for TNAFlix-style config
|
||||||
vkey = extract_field(r'<input\b[^>]+\bid="vkey"\b[^>]+\bvalue="([^"]+)"', 'vkey')
|
|
||||||
nkey = extract_field(r'<input\b[^>]+\bid="nkey"\b[^>]+\bvalue="([^"]+)"', 'nkey')
|
|
||||||
vid = extract_field(r'<input\b[^>]+\bid="VID"\b[^>]+\bvalue="([^"]+)"', 'vid')
|
|
||||||
if vkey and nkey and vid:
|
|
||||||
cfg_url = self._proto_relative_url(self._VIDEO_XML_URL.format(vkey, nkey, vid), 'http:')
|
|
||||||
|
|
||||||
if not cfg_url:
|
if not cfg_url:
|
||||||
inputs = self._hidden_inputs(webpage)
|
inputs = self._hidden_inputs(webpage)
|
||||||
cfg_url = ('https://cdn-fck.%sflix.com/%sflix/%s%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha'
|
if inputs.get('vkey') and inputs.get('nkey'):
|
||||||
% (self._HOST, self._HOST, inputs['vkey'], self._VKEY_SUFFIX, inputs['nkey'], video_id))
|
cfg_url = f'https://www.{host}.com/cdn/cdn.php'
|
||||||
|
query.update({
|
||||||
|
'file': inputs['vkey'],
|
||||||
|
'key': inputs['nkey'],
|
||||||
|
'VID': video_id,
|
||||||
|
'premium': '1',
|
||||||
|
'vip': '1',
|
||||||
|
'alpha': '',
|
||||||
|
})
|
||||||
|
|
||||||
|
formats, json_ld = [], {}
|
||||||
|
|
||||||
|
# TNAFlix and MovieFap extraction
|
||||||
|
if cfg_url:
|
||||||
cfg_xml = self._download_xml(
|
cfg_xml = self._download_xml(
|
||||||
cfg_url, display_id, 'Downloading metadata',
|
cfg_url, display_id, 'Downloading metadata',
|
||||||
transform_source=fix_xml_ampersands, headers={'Referer': url})
|
transform_source=fix_xml_ampersands, headers={'Referer': url}, query=query)
|
||||||
|
|
||||||
formats = []
|
|
||||||
|
|
||||||
def extract_video_url(vl):
|
def extract_video_url(vl):
|
||||||
# Any URL modification now results in HTTP Error 403: Forbidden
|
# Any URL modification now results in HTTP Error 403: Forbidden
|
||||||
@ -133,75 +135,85 @@ def extract_video_url(vl):
|
|||||||
'height': height,
|
'height': height,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
thumbnails = self._extract_thumbnails(cfg_xml) or []
|
||||||
|
thumbnails.append({
|
||||||
|
'url': self._proto_relative_url(xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
|
||||||
|
})
|
||||||
|
|
||||||
|
# check for EMPFlix-style JSON and extract
|
||||||
|
else:
|
||||||
|
player = self._download_json(
|
||||||
|
f'http://www.{host}.com/ajax/video-player/{video_id}', video_id,
|
||||||
|
headers={'Referer': url}).get('html', '')
|
||||||
|
for mobj in re.finditer(r'<source src="(?P<src>[^"]+)"', player):
|
||||||
|
video_url = mobj.group('src')
|
||||||
|
height = self._search_regex(r'-(\d+)p\.', url_basename(video_url), 'height', default=None)
|
||||||
|
formats.append({
|
||||||
|
'url': self._proto_relative_url(video_url, 'http:'),
|
||||||
|
'ext': url_basename(video_url).split('.')[-1],
|
||||||
|
'height': int_or_none(height),
|
||||||
|
'format_id': f'{height}p' if height else url_basename(video_url).split('.')[0],
|
||||||
|
})
|
||||||
|
thumbnail = self._proto_relative_url(self._search_regex(
|
||||||
|
r'data-poster="([^"]+)"', player, 'thumbnail', default=None), 'http:')
|
||||||
|
thumbnails = [{'url': thumbnail}] if thumbnail else None
|
||||||
|
json_ld = self._search_json_ld(webpage, display_id, default={})
|
||||||
|
|
||||||
|
def extract_field(pattern, name):
|
||||||
|
return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnail = self._proto_relative_url(
|
|
||||||
xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
|
|
||||||
thumbnails = self._extract_thumbnails(cfg_xml)
|
|
||||||
|
|
||||||
title = None
|
|
||||||
if self._TITLE_REGEX:
|
|
||||||
title = self._html_search_regex(
|
|
||||||
self._TITLE_REGEX, webpage, 'title', default=None)
|
|
||||||
if not title:
|
|
||||||
title = self._og_search_title(webpage)
|
|
||||||
|
|
||||||
age_limit = self._rta_search(webpage) or 18
|
|
||||||
|
|
||||||
duration = parse_duration(self._html_search_meta(
|
|
||||||
'duration', webpage, 'duration', default=None))
|
|
||||||
|
|
||||||
description = extract_field(self._DESCRIPTION_REGEX, 'description')
|
|
||||||
uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
|
|
||||||
view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
|
|
||||||
comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
|
|
||||||
average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
|
|
||||||
|
|
||||||
categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
|
|
||||||
categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else []
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'title': title,
|
'title': (extract_field(self._TITLE_REGEX, 'title')
|
||||||
'description': description,
|
or self._og_search_title(webpage, default=None)
|
||||||
'thumbnail': thumbnail,
|
or json_ld.get('title')),
|
||||||
|
'description': extract_field(self._DESCRIPTION_REGEX, 'description') or json_ld.get('description'),
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'duration': duration,
|
'duration': parse_duration(
|
||||||
'age_limit': age_limit,
|
self._html_search_meta('duration', webpage, 'duration', default=None)) or json_ld.get('duration'),
|
||||||
'uploader': uploader,
|
'age_limit': self._rta_search(webpage) or 18,
|
||||||
'view_count': view_count,
|
'uploader': extract_field(self._UPLOADER_REGEX, 'uploader') or json_ld.get('uploader'),
|
||||||
'comment_count': comment_count,
|
'view_count': str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count')),
|
||||||
'average_rating': average_rating,
|
'comment_count': str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count')),
|
||||||
'categories': categories,
|
'average_rating': float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating')),
|
||||||
|
'categories': list(map(str.strip, (extract_field(self._CATEGORIES_REGEX, 'categories') or '').split(','))),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
|
class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
|
||||||
_VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
|
_VALID_URL = r'https?://player\.(?P<host>tnaflix|empflix)\.com/video/(?P<id>\d+)'
|
||||||
_EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1']
|
_EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1']
|
||||||
|
|
||||||
_TITLE_REGEX = r'<title>([^<]+)</title>'
|
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://player.tnaflix.com/video/6538',
|
'url': 'https://player.tnaflix.com/video/6538',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6538',
|
'id': '6538',
|
||||||
'display_id': '6538',
|
'display_id': '6538',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Educational xxx video',
|
'title': 'Educational xxx video (G Spot)',
|
||||||
|
'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
|
||||||
'thumbnail': r're:https?://.*\.jpg$',
|
'thumbnail': r're:https?://.*\.jpg$',
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
|
'duration': 164,
|
||||||
|
'uploader': 'bobwhite39',
|
||||||
|
'categories': list,
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://player.empflix.com/video/33051',
|
'url': 'http://player.empflix.com/video/33051',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
mobj = self._match_valid_url(url)
|
||||||
|
video_id, host = mobj.group('id', 'host')
|
||||||
|
return self.url_result(f'http://www.{host}.com/category/{video_id}/video{video_id}')
|
||||||
|
|
||||||
|
|
||||||
class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
|
class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
|
||||||
_DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<'
|
_DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<'
|
||||||
@ -210,7 +222,7 @@ class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
|
|||||||
|
|
||||||
|
|
||||||
class TNAFlixIE(TNAEMPFlixBaseIE):
|
class TNAFlixIE(TNAEMPFlixBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?(?P<host>tnaflix)\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
|
||||||
|
|
||||||
_TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
|
_TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
|
||||||
|
|
||||||
@ -226,17 +238,17 @@ class TNAFlixIE(TNAEMPFlixBaseIE):
|
|||||||
'thumbnail': r're:https?://.*\.jpg$',
|
'thumbnail': r're:https?://.*\.jpg$',
|
||||||
'duration': 91,
|
'duration': 91,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'categories': ['Porn Stars'],
|
'categories': list,
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
# non-anonymous uploader, categories
|
# non-anonymous uploader, categories
|
||||||
'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
|
'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
|
||||||
'md5': '0f5d4d490dbfd117b8607054248a07c0',
|
'md5': 'add5a9fa7f4da53d3e9d0845ac58f20c',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6538',
|
'id': '6538',
|
||||||
'display_id': 'Educational-xxx-video',
|
'display_id': 'Educational-xxx-video',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Educational xxx video',
|
'title': 'Educational xxx video (G Spot)',
|
||||||
'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
|
'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
|
||||||
'thumbnail': r're:https?://.*\.jpg$',
|
'thumbnail': r're:https?://.*\.jpg$',
|
||||||
'duration': 164,
|
'duration': 164,
|
||||||
@ -251,14 +263,11 @@ class TNAFlixIE(TNAEMPFlixBaseIE):
|
|||||||
|
|
||||||
|
|
||||||
class EMPFlixIE(TNAEMPFlixBaseIE):
|
class EMPFlixIE(TNAEMPFlixBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?(?P<host>empflix)\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
|
||||||
|
|
||||||
_HOST = 'emp'
|
|
||||||
_VKEY_SUFFIX = '-1'
|
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
|
'url': 'http://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
|
||||||
'md5': 'bc30d48b91a7179448a0bda465114676',
|
'md5': 'd761c7b26601bd14476cd9512f2654fc',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '33051',
|
'id': '33051',
|
||||||
'display_id': 'Amateur-Finger-Fuck',
|
'display_id': 'Amateur-Finger-Fuck',
|
||||||
@ -268,20 +277,20 @@ class EMPFlixIE(TNAEMPFlixBaseIE):
|
|||||||
'thumbnail': r're:https?://.*\.jpg$',
|
'thumbnail': r're:https?://.*\.jpg$',
|
||||||
'duration': 83,
|
'duration': 83,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'uploader': 'cwbike',
|
'uploader': None,
|
||||||
'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
|
'categories': list,
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
|
'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
|
'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
class MovieFapIE(TNAFlixNetworkBaseIE):
|
class MovieFapIE(TNAFlixNetworkBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
|
_VALID_URL = r'https?://(?:www\.)?(?P<host>moviefap)\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
|
||||||
|
|
||||||
_VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
|
_VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
|
||||||
_COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
|
_COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
|
||||||
@ -323,5 +332,6 @@ class MovieFapIE(TNAFlixNetworkBaseIE):
|
|||||||
'comment_count': int,
|
'comment_count': int,
|
||||||
'average_rating': float,
|
'average_rating': float,
|
||||||
'categories': ['Amateur', 'Teen'],
|
'categories': ['Amateur', 'Teen'],
|
||||||
}
|
},
|
||||||
|
'skip': 'This video does not exist',
|
||||||
}]
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user