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\("([^"]+)"',
22 r'<input[^>]+name="config\d?" value="([^"]+)"',
26 _TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"'
27 _DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"'
28 _UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"'
29 _VIEW_COUNT_REGEX = None
30 _COMMENT_COUNT_REGEX = None
31 _AVERAGE_RATING_REGEX = None
32 _CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle"[^>]*>Categories:</span>\s*<span[^>]+class="listView"[^>]*>(.+?)</span>\s*</li>'
34 def _extract_thumbnails(self, flix_xml):
36 def get_child(elem, names):
38 child = elem.find(name)
42 timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage'])
46 pattern_el = get_child(timeline, ['imagePattern', 'pattern'])
47 if pattern_el is None or not pattern_el.text:
50 first_el = get_child(timeline, ['imageFirst', 'first'])
51 last_el = get_child(timeline, ['imageLast', 'last'])
52 if first_el is None or last_el is None:
55 first_text = first_el.text
56 last_text = last_el.text
57 if not first_text.isdigit() or not last_text.isdigit():
60 first = int(first_text)
65 width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width'))
66 height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height'))
69 'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'),
72 } for i in range(first, last + 1)]
74 def _real_extract(self, url):
75 mobj = re.match(self._VALID_URL, url)
76 video_id = mobj.group('id')
77 for display_id_key in ('display_id', 'display_id_2'):
78 if display_id_key in mobj.groupdict():
79 display_id = mobj.group(display_id_key)
85 webpage = self._download_webpage(url, display_id)
87 cfg_url = self._proto_relative_url(self._html_search_regex(
88 self._CONFIG_REGEX, webpage, 'flashvars.config', default=None), 'http:')
91 inputs = self._hidden_inputs(webpage)
92 cfg_url = ('https://cdn-fck.%sflix.com/%sflix/%s%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha'
93 % (self._HOST, self._HOST, inputs['vkey'], self._VKEY_SUFFIX, inputs['nkey'], video_id))
95 cfg_xml = self._download_xml(
96 cfg_url, display_id, 'Downloading metadata',
97 transform_source=fix_xml_ampersands)
101 def extract_video_url(vl):
102 # Any URL modification now results in HTTP Error 403: Forbidden
103 return unescapeHTML(vl.text)
105 video_link = cfg_xml.find('./videoLink')
106 if video_link is not None:
108 'url': extract_video_url(video_link),
109 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
112 for item in cfg_xml.findall('./quality/item'):
113 video_link = item.find('./videoLink')
114 if video_link is None:
116 res = item.find('res')
117 format_id = None if res is None else res.text
118 height = int_or_none(self._search_regex(
119 r'^(\d+)[pP]', format_id, 'height', default=None))
121 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
122 'format_id': format_id,
126 self._sort_formats(formats)
128 thumbnail = self._proto_relative_url(
129 xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
130 thumbnails = self._extract_thumbnails(cfg_xml)
133 if self._TITLE_REGEX:
134 title = self._html_search_regex(
135 self._TITLE_REGEX, webpage, 'title', default=None)
137 title = self._og_search_title(webpage)
139 age_limit = self._rta_search(webpage) or 18
141 duration = parse_duration(self._html_search_meta(
142 'duration', webpage, 'duration', default=None))
144 def extract_field(pattern, name):
145 return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
147 description = extract_field(self._DESCRIPTION_REGEX, 'description')
148 uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
149 view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
150 comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
151 average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
153 categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
154 categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else []
158 'display_id': display_id,
160 'description': description,
161 'thumbnail': thumbnail,
162 'thumbnails': thumbnails,
163 'duration': duration,
164 'age_limit': age_limit,
165 'uploader': uploader,
166 'view_count': view_count,
167 'comment_count': comment_count,
168 'average_rating': average_rating,
169 'categories': categories,
174 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
175 _VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
177 _TITLE_REGEX = r'<title>([^<]+)</title>'
180 'url': 'https://player.tnaflix.com/video/6538',
183 'display_id': '6538',
185 'title': 'Educational xxx video',
186 'thumbnail': r're:https?://.*\.jpg$',
190 'skip_download': True,
193 'url': 'https://player.empflix.com/video/33051',
194 'only_matching': True,
198 def _extract_urls(webpage):
199 return [url for _, url in re.findall(
200 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1',
204 class TNAFlixIE(TNAFlixNetworkBaseIE):
205 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
207 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
208 _DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<'
209 _UPLOADER_REGEX = r'<i>\s*Verified Member\s*</i>\s*<h\d+>(.+?)<'
210 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
213 # anonymous uploader, no categories
214 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
215 'md5': 'ecf3498417d09216374fc5907f9c6ec0',
218 'display_id': 'Carmella-Decesare-striptease',
220 'title': 'Carmella Decesare - striptease',
221 'thumbnail': r're:https?://.*\.jpg$',
224 'categories': ['Porn Stars'],
227 # non-anonymous uploader, categories
228 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
229 'md5': '0f5d4d490dbfd117b8607054248a07c0',
232 'display_id': 'Educational-xxx-video',
234 'title': 'Educational xxx video',
235 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
236 'thumbnail': r're:https?://.*\.jpg$',
239 'uploader': 'bobwhite39',
240 'categories': ['Amateur Porn', 'Squirting Videos', 'Teen Girls 18+'],
243 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
244 'only_matching': True,
248 class EMPFlixIE(TNAFlixNetworkBaseIE):
249 _VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
253 _UPLOADER_REGEX = r'<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)</li>'
256 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
257 'md5': 'b1bc15b6412d33902d6e5952035fcabc',
260 'display_id': 'Amateur-Finger-Fuck',
262 'title': 'Amateur Finger Fuck',
263 'description': 'Amateur solo finger fucking.',
264 'thumbnail': r're:https?://.*\.jpg$',
267 'uploader': 'cwbike',
268 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
271 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
272 'only_matching': True,
274 'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
275 'only_matching': True,
279 class MovieFapIE(TNAFlixNetworkBaseIE):
280 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
282 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
283 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
284 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
285 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
288 # normal, multi-format video
289 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
290 'md5': '26624b4e2523051b550067d547615906',
292 'id': 'be9867c9416c19f54a4a',
293 'display_id': 'experienced-milf-amazing-handjob',
295 'title': 'Experienced MILF Amazing Handjob',
296 'description': 'Experienced MILF giving an Amazing Handjob',
297 'thumbnail': r're:https?://.*\.jpg$',
299 'uploader': 'darvinfred06',
301 'comment_count': int,
302 'average_rating': float,
303 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
306 # quirky single-format case where the extension is given as fid, but the video is really an flv
307 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
308 'md5': 'fa56683e291fc80635907168a743c9ad',
310 'id': 'e5da0d3edce5404418f5',
311 'display_id': 'jeune-couple-russe',
313 'title': 'Jeune Couple Russe',
314 'description': 'Amateur',
315 'thumbnail': r're:https?://.*\.jpg$',
317 'uploader': 'whiskeyjar',
319 'comment_count': int,
320 'average_rating': float,
321 'categories': ['Amateur', 'Teen'],