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="([^"]+)"',
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 = re.match(self._VALID_URL, url)
74 video_id = mobj.group('id')
75 display_id = mobj.group('display_id') if 'display_id' in mobj.groupdict() else video_id
77 webpage = self._download_webpage(url, display_id)
79 cfg_url = self._proto_relative_url(self._html_search_regex(
80 self._CONFIG_REGEX, webpage, 'flashvars.config', default=None), 'http:')
83 inputs = self._hidden_inputs(webpage)
84 cfg_url = ('https://cdn-fck.tnaflix.com/tnaflix/%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha'
85 % (inputs['vkey'], inputs['nkey'], video_id))
87 cfg_xml = self._download_xml(
88 cfg_url, display_id, 'Downloading metadata',
89 transform_source=fix_xml_ampersands)
93 def extract_video_url(vl):
94 return re.sub(r'speed=\d+', 'speed=', unescapeHTML(vl.text))
96 video_link = cfg_xml.find('./videoLink')
97 if video_link is not None:
99 'url': extract_video_url(video_link),
100 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
103 for item in cfg_xml.findall('./quality/item'):
104 video_link = item.find('./videoLink')
105 if video_link is None:
107 res = item.find('res')
108 format_id = None if res is None else res.text
109 height = int_or_none(self._search_regex(
110 r'^(\d+)[pP]', format_id, 'height', default=None))
112 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
113 'format_id': format_id,
117 self._sort_formats(formats)
119 thumbnail = self._proto_relative_url(
120 xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
121 thumbnails = self._extract_thumbnails(cfg_xml)
124 if self._TITLE_REGEX:
125 title = self._html_search_regex(
126 self._TITLE_REGEX, webpage, 'title', default=None)
128 title = self._og_search_title(webpage)
130 age_limit = self._rta_search(webpage) or 18
132 duration = parse_duration(self._html_search_meta(
133 'duration', webpage, 'duration', default=None))
135 def extract_field(pattern, name):
136 return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
138 description = extract_field(self._DESCRIPTION_REGEX, 'description')
139 uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
140 view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
141 comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
142 average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
144 categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
145 categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else []
149 'display_id': display_id,
151 'description': description,
152 'thumbnail': thumbnail,
153 'thumbnails': thumbnails,
154 'duration': duration,
155 'age_limit': age_limit,
156 'uploader': uploader,
157 'view_count': view_count,
158 'comment_count': comment_count,
159 'average_rating': average_rating,
160 'categories': categories,
165 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
166 _VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
168 _TITLE_REGEX = r'<title>([^<]+)</title>'
171 'url': 'https://player.tnaflix.com/video/6538',
174 'display_id': '6538',
176 'title': 'Educational xxx video',
177 'thumbnail': r're:https?://.*\.jpg$',
181 'skip_download': True,
184 'url': 'https://player.empflix.com/video/33051',
185 'only_matching': True,
189 def _extract_urls(webpage):
190 return [url for _, url in re.findall(
191 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.(?:tna|emp)flix\.com/video/\d+)\1',
195 class TNAFlixIE(TNAFlixNetworkBaseIE):
196 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
198 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
199 _DESCRIPTION_REGEX = r'(?s)>Description:</[^>]+>(.+?)<'
200 _UPLOADER_REGEX = r'<i>\s*Verified Member\s*</i>\s*<h\d+>(.+?)<'
201 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
204 # anonymous uploader, no categories
205 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
206 'md5': 'ecf3498417d09216374fc5907f9c6ec0',
209 'display_id': 'Carmella-Decesare-striptease',
211 'title': 'Carmella Decesare - striptease',
212 'thumbnail': r're:https?://.*\.jpg$',
215 'categories': ['Porn Stars'],
218 # non-anonymous uploader, categories
219 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
220 'md5': '0f5d4d490dbfd117b8607054248a07c0',
223 'display_id': 'Educational-xxx-video',
225 'title': 'Educational xxx video',
226 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
227 'thumbnail': r're:https?://.*\.jpg$',
230 'uploader': 'bobwhite39',
231 'categories': ['Amateur Porn', 'Squirting Videos', 'Teen Girls 18+'],
234 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
235 'only_matching': True,
239 class EMPFlixIE(TNAFlixNetworkBaseIE):
240 _VALID_URL = r'https?://(?:www\.)?empflix\.com/videos/(?P<display_id>.+?)-(?P<id>[0-9]+)\.html'
242 _UPLOADER_REGEX = r'<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)</li>'
245 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
246 'md5': 'b1bc15b6412d33902d6e5952035fcabc',
249 'display_id': 'Amateur-Finger-Fuck',
251 'title': 'Amateur Finger Fuck',
252 'description': 'Amateur solo finger fucking.',
253 'thumbnail': r're:https?://.*\.jpg$',
256 'uploader': 'cwbike',
257 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
260 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
261 'only_matching': True,
265 class MovieFapIE(TNAFlixNetworkBaseIE):
266 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
268 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
269 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
270 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
271 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
274 # normal, multi-format video
275 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
276 'md5': '26624b4e2523051b550067d547615906',
278 'id': 'be9867c9416c19f54a4a',
279 'display_id': 'experienced-milf-amazing-handjob',
281 'title': 'Experienced MILF Amazing Handjob',
282 'description': 'Experienced MILF giving an Amazing Handjob',
283 'thumbnail': r're:https?://.*\.jpg$',
285 'uploader': 'darvinfred06',
287 'comment_count': int,
288 'average_rating': float,
289 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
292 # quirky single-format case where the extension is given as fid, but the video is really an flv
293 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
294 'md5': 'fa56683e291fc80635907168a743c9ad',
296 'id': 'e5da0d3edce5404418f5',
297 'display_id': 'jeune-couple-russe',
299 'title': 'Jeune Couple Russe',
300 'description': 'Amateur',
301 'thumbnail': r're:https?://.*\.jpg$',
303 'uploader': 'whiskeyjar',
305 'comment_count': int,
306 'average_rating': float,
307 'categories': ['Amateur', 'Teen'],