1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_str
18 class TNAFlixNetworkBaseIE(InfoExtractor):
19 # May be overridden in descendants if necessary
21 r'flashvars\.config\s*=\s*escape\("(?P<url>[^"]+)"',
22 r'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"',
23 r'config\s*=\s*(["\'])(?P<url>(?:https?:)?//(?:(?!\1).)+)\1',
27 _TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"'
28 _DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"'
29 _UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"'
30 _VIEW_COUNT_REGEX = None
31 _COMMENT_COUNT_REGEX = None
32 _AVERAGE_RATING_REGEX = None
33 _CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle"[^>]*>Categories:</span>\s*<span[^>]+class="listView"[^>]*>(.+?)</span>\s*</li>'
35 def _extract_thumbnails(self, flix_xml):
37 def get_child(elem, names):
39 child = elem.find(name)
43 timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage'])
47 pattern_el = get_child(timeline, ['imagePattern', 'pattern'])
48 if pattern_el is None or not pattern_el.text:
51 first_el = get_child(timeline, ['imageFirst', 'first'])
52 last_el = get_child(timeline, ['imageLast', 'last'])
53 if first_el is None or last_el is None:
56 first_text = first_el.text
57 last_text = last_el.text
58 if not first_text.isdigit() or not last_text.isdigit():
61 first = int(first_text)
66 width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width'))
67 height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height'))
70 'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'),
73 } for i in range(first, last + 1)]
75 def _real_extract(self, url):
76 mobj = re.match(self._VALID_URL, url)
77 video_id = mobj.group('id')
78 for display_id_key in ('display_id', 'display_id_2'):
79 if display_id_key in mobj.groupdict():
80 display_id = mobj.group(display_id_key)
86 webpage = self._download_webpage(url, display_id)
88 cfg_url = self._proto_relative_url(self._html_search_regex(
89 self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
90 group='url'), 'http:')
93 inputs = self._hidden_inputs(webpage)
94 cfg_url = ('https://cdn-fck.%sflix.com/%sflix/%s%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha'
95 % (self._HOST, self._HOST, inputs['vkey'], self._VKEY_SUFFIX, inputs['nkey'], video_id))
97 cfg_xml = self._download_xml(
98 cfg_url, display_id, 'Downloading metadata',
99 transform_source=fix_xml_ampersands, headers={'Referer': url})
103 def extract_video_url(vl):
104 # Any URL modification now results in HTTP Error 403: Forbidden
105 return unescapeHTML(vl.text)
107 video_link = cfg_xml.find('./videoLink')
108 if video_link is not None:
110 'url': extract_video_url(video_link),
111 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
114 for item in cfg_xml.findall('./quality/item'):
115 video_link = item.find('./videoLink')
116 if video_link is None:
118 res = item.find('res')
119 format_id = None if res is None else res.text
120 height = int_or_none(self._search_regex(
121 r'^(\d+)[pP]', format_id, 'height', default=None))
123 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
124 'format_id': format_id,
128 self._sort_formats(formats)
130 thumbnail = self._proto_relative_url(
131 xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
132 thumbnails = self._extract_thumbnails(cfg_xml)
135 if self._TITLE_REGEX:
136 title = self._html_search_regex(
137 self._TITLE_REGEX, webpage, 'title', default=None)
139 title = self._og_search_title(webpage)
141 age_limit = self._rta_search(webpage) or 18
143 duration = parse_duration(self._html_search_meta(
144 'duration', webpage, 'duration', default=None))
146 def extract_field(pattern, name):
147 return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
149 description = extract_field(self._DESCRIPTION_REGEX, 'description')
150 uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
151 view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
152 comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
153 average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
155 categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
156 categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else []
160 'display_id': display_id,
162 'description': description,
163 'thumbnail': thumbnail,
164 'thumbnails': thumbnails,
165 'duration': duration,
166 'age_limit': age_limit,
167 'uploader': uploader,
168 'view_count': view_count,
169 'comment_count': comment_count,
170 'average_rating': average_rating,
171 'categories': categories,
176 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
177 _VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
179 _TITLE_REGEX = r'<title>([^<]+)</title>'
182 'url': 'https://player.tnaflix.com/video/6538',
185 'display_id': '6538',
187 'title': 'Educational xxx video',
188 'thumbnail': r're:https?://.*\.jpg$',
192 'skip_download': True,
195 'url': 'https://player.empflix.com/video/33051',
196 'only_matching': True,
200 def _extract_urls(webpage):
201 return [url for _, url in re.findall(
202 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1',
206 class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
207 _DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<'
208 _UPLOADER_REGEX = r'<span>by\s*<a[^>]+\bhref=["\']/profile/[^>]+>([^<]+)<'
209 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
212 class TNAFlixIE(TNAEMPFlixBaseIE):
213 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
215 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
218 # anonymous uploader, no categories
219 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
220 'md5': '7e569419fe6d69543d01e6be22f5f7c4',
223 'display_id': 'Carmella-Decesare-striptease',
225 'title': 'Carmella Decesare - striptease',
226 'thumbnail': r're:https?://.*\.jpg$',
229 'categories': ['Porn Stars'],
232 # non-anonymous uploader, categories
233 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
234 'md5': '0f5d4d490dbfd117b8607054248a07c0',
237 'display_id': 'Educational-xxx-video',
239 'title': 'Educational xxx video',
240 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
241 'thumbnail': r're:https?://.*\.jpg$',
244 'uploader': 'bobwhite39',
248 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
249 'only_matching': True,
253 class EMPFlixIE(TNAEMPFlixBaseIE):
254 _VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
260 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
261 'md5': 'bc30d48b91a7179448a0bda465114676',
264 'display_id': 'Amateur-Finger-Fuck',
266 'title': 'Amateur Finger Fuck',
267 'description': 'Amateur solo finger fucking.',
268 'thumbnail': r're:https?://.*\.jpg$',
271 'uploader': 'cwbike',
272 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
275 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
276 'only_matching': True,
278 'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
279 'only_matching': True,
283 class MovieFapIE(TNAFlixNetworkBaseIE):
284 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
286 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
287 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
288 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
289 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
292 # normal, multi-format video
293 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
294 'md5': '26624b4e2523051b550067d547615906',
296 'id': 'be9867c9416c19f54a4a',
297 'display_id': 'experienced-milf-amazing-handjob',
299 'title': 'Experienced MILF Amazing Handjob',
300 'description': 'Experienced MILF giving an Amazing Handjob',
301 'thumbnail': r're:https?://.*\.jpg$',
303 'uploader': 'darvinfred06',
305 'comment_count': int,
306 'average_rating': float,
307 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
310 # quirky single-format case where the extension is given as fid, but the video is really an flv
311 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
312 'md5': 'fa56683e291fc80635907168a743c9ad',
314 'id': 'e5da0d3edce5404418f5',
315 'display_id': 'jeune-couple-russe',
317 'title': 'Jeune Couple Russe',
318 'description': 'Amateur',
319 'thumbnail': r're:https?://.*\.jpg$',
321 'uploader': 'whiskeyjar',
323 'comment_count': int,
324 'average_rating': float,
325 'categories': ['Amateur', 'Teen'],