3 from .common
import InfoExtractor
4 from ..compat
import compat_str
17 class TNAFlixNetworkBaseIE(InfoExtractor
):
18 # May be overridden in descendants if necessary
20 r
'flashvars\.config\s*=\s*escape\("(?P<url>[^"]+)"',
21 r
'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"',
22 r
'config\s*=\s*(["\'])(?P
<url
>(?
:https?
:)?
//(?
:(?
!\
1).)+)\
1',
24 _TITLE_REGEX = r'<input[^
>]+name
="title" value
="([^"]+)"'
25 _DESCRIPTION_REGEX = r'<input[^>]+name="description
" value="([^
"]+)"'
26 _UPLOADER_REGEX = r'<input[^
>]+name
="username" value
="([^"]+)"'
27 _VIEW_COUNT_REGEX = None
28 _COMMENT_COUNT_REGEX = None
29 _AVERAGE_RATING_REGEX = None
30 _CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle
"[^>]*>Categories:</span>\s*<span[^>]+class="listView
"[^>]*>(.+?)</span>\s*</li>'
32 def _extract_thumbnails(self, flix_xml):
34 def get_child(elem, names):
36 child = elem.find(name)
40 timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage'])
44 pattern_el = get_child(timeline, ['imagePattern', 'pattern'])
45 if pattern_el is None or not pattern_el.text:
48 first_el = get_child(timeline, ['imageFirst', 'first'])
49 last_el = get_child(timeline, ['imageLast', 'last'])
50 if first_el is None or last_el is None:
53 first_text = first_el.text
54 last_text = last_el.text
55 if not first_text.isdigit() or not last_text.isdigit():
58 first = int(first_text)
63 width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width'))
64 height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height'))
67 'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'),
70 } for i in range(first, last + 1)]
72 def _real_extract(self, url):
73 mobj = self._match_valid_url(url)
74 video_id, host = mobj.group('id', 'host')
75 for display_id_key in ('display_id', 'display_id_2'):
76 if display_id_key in mobj.groupdict():
77 display_id = mobj.group(display_id_key)
83 webpage = self._download_webpage(url, display_id)
85 # check for MovieFap-style config
86 cfg_url = self._proto_relative_url(self._html_search_regex(
87 self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
88 group='url'), 'http:')
91 # check for TNAFlix-style config
93 inputs = self._hidden_inputs(webpage)
94 if inputs.get('vkey') and inputs.get('nkey'):
95 cfg_url = f'https://www.{host}.com/cdn/cdn.php'
97 'file': inputs['vkey'],
98 'key': inputs['nkey'],
105 formats, json_ld = [], {}
107 # TNAFlix and MovieFap extraction
109 cfg_xml = self._download_xml(
110 cfg_url, display_id, 'Downloading metadata',
111 transform_source=fix_xml_ampersands, headers={'Referer': url}, query=query)
113 def extract_video_url(vl):
114 # Any URL modification now results in HTTP Error 403: Forbidden
115 return unescapeHTML(vl.text)
117 video_link = cfg_xml.find('./videoLink')
118 if video_link is not None:
120 'url': extract_video_url(video_link),
121 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
124 for item in cfg_xml.findall('./quality/item'):
125 video_link = item.find('./videoLink')
126 if video_link is None:
128 res = item.find('res')
129 format_id = None if res is None else res.text
130 height = int_or_none(self._search_regex(
131 r'^(\d+)[pP]', format_id, 'height', default=None))
133 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
134 'format_id': format_id,
138 thumbnails = self._extract_thumbnails(cfg_xml) or []
140 'url': self._proto_relative_url(xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
143 # check for EMPFlix-style JSON and extract
145 player = self._download_json(
146 f'http://www.{host}.com/ajax/video-player/{video_id}', video_id,
147 headers={'Referer': url}).get('html', '')
148 for mobj in re.finditer(r'<source src="(?P
<src
>[^
"]+)"', player):
149 video_url = mobj.group('src
')
150 height = self._search_regex(r'-(\d
+)p\
.', url_basename(video_url), 'height
', default=None)
152 'url
': self._proto_relative_url(video_url, 'http
:'),
153 'ext
': url_basename(video_url).split('.')[-1],
154 'height
': int_or_none(height),
155 'format_id
': f'{height}p
' if height else url_basename(video_url).split('.')[0],
157 thumbnail = self._proto_relative_url(self._search_regex(
158 r'data
-poster
="([^"]+)"', player, 'thumbnail', default=None), 'http:')
159 thumbnails = [{'url': thumbnail}] if thumbnail else None
160 json_ld = self._search_json_ld(webpage, display_id, default={})
162 def extract_field(pattern, name):
163 return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
167 'display_id': display_id,
168 'title': (extract_field(self._TITLE_REGEX, 'title')
169 or self._og_search_title(webpage, default=None)
170 or json_ld.get('title')),
171 'description': extract_field(self._DESCRIPTION_REGEX, 'description') or json_ld.get('description'),
172 'thumbnails': thumbnails,
173 'duration': parse_duration(
174 self._html_search_meta('duration', webpage, 'duration', default=None)) or json_ld.get('duration'),
175 'age_limit': self._rta_search(webpage) or 18,
176 'uploader': extract_field(self._UPLOADER_REGEX, 'uploader') or json_ld.get('uploader'),
177 'view_count': str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count')),
178 'comment_count': str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count')),
179 'average_rating': float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating')),
180 'categories': list(map(str.strip, (extract_field(self._CATEGORIES_REGEX, 'categories') or '').split(','))),
185 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
186 _VALID_URL = r'https?://player\.(?P<host>tnaflix|empflix)\.com/video/(?P<id>\d+)'
187 _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.(?
:tna|emp
)flix\
.com
/video
/\d
+)\
1']
190 'url
': 'https
://player
.tnaflix
.com
/video
/6538',
193 'display_id
': '6538',
195 'title
': 'Educational xxx
video (G Spot
)',
196 'description
': 'md5
:b4fab8f88a8621c8fabd361a173fe5b8
',
197 'thumbnail
': r're
:https?
://.*\
.jpg$
',
200 'uploader
': 'bobwhite39
',
204 'skip_download
': True,
207 'url
': 'http
://player
.empflix
.com
/video
/33051',
208 'only_matching
': True,
211 def _real_extract(self, url):
212 mobj = self._match_valid_url(url)
213 video_id, host = mobj.group('id', 'host
')
214 return self.url_result(f'http
://www
.{host}
.com
/category
/{video_id}
/video{video_id}
')
217 class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
218 _DESCRIPTION_REGEX = r'(?s
)>Description
:</[^
>]+>(.+?
)<'
219 _UPLOADER_REGEX = r'<span
>by\s
*<a
[^
>]+\bhref
=["\']/profile/[^>]+>([^<]+)<'
220 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
223 class TNAFlixIE(TNAEMPFlixBaseIE):
224 _VALID_URL = r'https?://(?:www\.)?(?P<host>tnaflix)\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
226 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
229 # anonymous uploader, no categories
230 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
231 'md5': '7e569419fe6d69543d01e6be22f5f7c4',
234 'display_id': 'Carmella-Decesare-striptease',
236 'title': 'Carmella Decesare - striptease',
237 'thumbnail': r're:https?://.*\.jpg$',
243 # non-anonymous uploader, categories
244 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
245 'md5': 'add5a9fa7f4da53d3e9d0845ac58f20c',
248 'display_id': 'Educational-xxx-video',
250 'title': 'Educational xxx video (G Spot)',
251 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
252 'thumbnail': r're:https?://.*\.jpg$',
255 'uploader': 'bobwhite39',
259 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
260 'only_matching': True,
264 class EMPFlixIE(TNAEMPFlixBaseIE):
265 _VALID_URL = r'https?://(?:www\.)?(?P<host>empflix)\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
268 'url': 'http://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
269 'md5': 'd761c7b26601bd14476cd9512f2654fc',
272 'display_id': 'Amateur-Finger-Fuck',
274 'title': 'Amateur Finger Fuck',
275 'description': 'Amateur solo finger fucking.',
276 'thumbnail': r're:https?://.*\.jpg$',
283 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
284 'only_matching': True,
286 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
287 'only_matching': True,
291 class MovieFapIE(TNAFlixNetworkBaseIE):
292 _VALID_URL = r'https?://(?:www\.)?(?P<host>moviefap)\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
294 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
295 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount
"[^>]*>([\d,.]+)</span>'
296 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
297 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info
"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
300 # normal, multi-format video
301 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
302 'md5': '26624b4e2523051b550067d547615906',
304 'id': 'be9867c9416c19f54a4a',
305 'display_id': 'experienced-milf-amazing-handjob',
307 'title': 'Experienced MILF Amazing Handjob',
308 'description': 'Experienced MILF giving an Amazing Handjob',
309 'thumbnail': r're:https?://.*\.jpg$',
311 'uploader': 'darvinfred06',
313 'comment_count': int,
314 'average_rating': float,
315 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
318 # quirky single-format case where the extension is given as fid, but the video is really an flv
319 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
320 'md5': 'fa56683e291fc80635907168a743c9ad',
322 'id': 'e5da0d3edce5404418f5',
323 'display_id': 'jeune-couple-russe',
325 'title': 'Jeune Couple Russe',
326 'description': 'Amateur',
327 'thumbnail': r're:https?://.*\.jpg$',
329 'uploader': 'whiskeyjar',
331 'comment_count': int,
332 'average_rating': float,
333 'categories': ['Amateur', 'Teen'],
335 'skip': 'This video does not exist',