]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tnaflix.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_str
14 class TNAFlixNetworkBaseIE(InfoExtractor
):
15 # May be overridden in descendants if necessary
17 r
'flashvars\.config\s*=\s*escape\("(?P<url>[^"]+)"',
18 r
'<input[^>]+name="config\d?" value="(?P<url>[^"]+)"',
19 r
'config\s*=\s*(["\'])(?P
<url
>(?
:https?
:)?
//(?
:(?
!\
1).)+)\
1',
23 _TITLE_REGEX = r'<input[^
>]+name
="title" value
="([^"]+)"'
24 _DESCRIPTION_REGEX = r'<input[^>]+name="description
" value="([^
"]+)"'
25 _UPLOADER_REGEX = r'<input[^
>]+name
="username" value
="([^"]+)"'
26 _VIEW_COUNT_REGEX = None
27 _COMMENT_COUNT_REGEX = None
28 _AVERAGE_RATING_REGEX = None
29 _CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle
"[^>]*>Categories:</span>\s*<span[^>]+class="listView
"[^>]*>(.+?)</span>\s*</li>'
31 def _extract_thumbnails(self, flix_xml):
33 def get_child(elem, names):
35 child = elem.find(name)
39 timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage'])
43 pattern_el = get_child(timeline, ['imagePattern', 'pattern'])
44 if pattern_el is None or not pattern_el.text:
47 first_el = get_child(timeline, ['imageFirst', 'first'])
48 last_el = get_child(timeline, ['imageLast', 'last'])
49 if first_el is None or last_el is None:
52 first_text = first_el.text
53 last_text = last_el.text
54 if not first_text.isdigit() or not last_text.isdigit():
57 first = int(first_text)
62 width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width'))
63 height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height'))
66 'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'),
69 } for i in range(first, last + 1)]
71 def _real_extract(self, url):
72 mobj = self._match_valid_url(url)
73 video_id = mobj.group('id')
74 for display_id_key in ('display_id', 'display_id_2'):
75 if display_id_key in mobj.groupdict():
76 display_id = mobj.group(display_id_key)
82 webpage = self._download_webpage(url, display_id)
84 cfg_url = self._proto_relative_url(self._html_search_regex(
85 self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
86 group='url'), 'http:')
89 inputs = self._hidden_inputs(webpage)
90 cfg_url = ('https://cdn-fck.%sflix.com/%sflix/%s%s.fid?key=%s&VID=%s&premium=1&vip=1&alpha'
91 % (self._HOST, self._HOST, inputs['vkey'], self._VKEY_SUFFIX, inputs['nkey'], video_id))
93 cfg_xml = self._download_xml(
94 cfg_url, display_id, 'Downloading metadata',
95 transform_source=fix_xml_ampersands, headers={'Referer': url})
99 def extract_video_url(vl):
100 # Any URL modification now results in HTTP Error 403: Forbidden
101 return unescapeHTML(vl.text)
103 video_link = cfg_xml.find('./videoLink')
104 if video_link is not None:
106 'url': extract_video_url(video_link),
107 'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
110 for item in cfg_xml.findall('./quality/item'):
111 video_link = item.find('./videoLink')
112 if video_link is None:
114 res = item.find('res')
115 format_id = None if res is None else res.text
116 height = int_or_none(self._search_regex(
117 r'^(\d+)[pP]', format_id, 'height', default=None))
119 'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
120 'format_id': format_id,
124 self._sort_formats(formats)
126 thumbnail = self._proto_relative_url(
127 xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
128 thumbnails = self._extract_thumbnails(cfg_xml)
131 if self._TITLE_REGEX:
132 title = self._html_search_regex(
133 self._TITLE_REGEX, webpage, 'title', default=None)
135 title = self._og_search_title(webpage)
137 age_limit = self._rta_search(webpage) or 18
139 duration = parse_duration(self._html_search_meta(
140 'duration', webpage, 'duration', default=None))
142 def extract_field(pattern, name):
143 return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
145 description = extract_field(self._DESCRIPTION_REGEX, 'description')
146 uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
147 view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
148 comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
149 average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
151 categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
152 categories = [c.strip() for c in categories_str.split(',')] if categories_str is not None else []
156 'display_id': display_id,
158 'description': description,
159 'thumbnail': thumbnail,
160 'thumbnails': thumbnails,
161 'duration': duration,
162 'age_limit': age_limit,
163 'uploader': uploader,
164 'view_count': view_count,
165 'comment_count': comment_count,
166 'average_rating': average_rating,
167 'categories': categories,
172 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE):
173 _VALID_URL = r'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
174 _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.(?
:tna|emp
)flix\
.com
/video
/\d
+)\
1']
176 _TITLE_REGEX = r'<title
>([^
<]+)</title
>'
179 'url
': 'https
://player
.tnaflix
.com
/video
/6538',
182 'display_id
': '6538',
184 'title
': 'Educational xxx video
',
185 'thumbnail
': r're
:https?
://.*\
.jpg$
',
189 'skip_download
': True,
192 'url
': 'https
://player
.empflix
.com
/video
/33051',
193 'only_matching
': True,
197 class TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
198 _DESCRIPTION_REGEX = r'(?s
)>Description
:</[^
>]+>(.+?
)<'
199 _UPLOADER_REGEX = r'<span
>by\s
*<a
[^
>]+\bhref
=["\']/profile/[^>]+>([^<]+)<'
200 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
203 class TNAFlixIE(TNAEMPFlixBaseIE):
204 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
206 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
209 # anonymous uploader, no categories
210 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
211 'md5': '7e569419fe6d69543d01e6be22f5f7c4',
214 'display_id': 'Carmella-Decesare-striptease',
216 'title': 'Carmella Decesare - striptease',
217 'thumbnail': r're:https?://.*\.jpg$',
220 'categories': ['Porn Stars'],
223 # non-anonymous uploader, categories
224 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
225 'md5': '0f5d4d490dbfd117b8607054248a07c0',
228 'display_id': 'Educational-xxx-video',
230 'title': 'Educational xxx video',
231 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
232 'thumbnail': r're:https?://.*\.jpg$',
235 'uploader': 'bobwhite39',
239 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
240 'only_matching': True,
244 class EMPFlixIE(TNAEMPFlixBaseIE):
245 _VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
251 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
252 'md5': 'bc30d48b91a7179448a0bda465114676',
255 'display_id': 'Amateur-Finger-Fuck',
257 'title': 'Amateur Finger Fuck',
258 'description': 'Amateur solo finger fucking.',
259 'thumbnail': r're:https?://.*\.jpg$',
262 'uploader': 'cwbike',
263 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
266 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
267 'only_matching': True,
269 'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
270 'only_matching': True,
274 class MovieFapIE(TNAFlixNetworkBaseIE):
275 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
277 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
278 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount
"[^>]*>([\d,.]+)</span>'
279 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
280 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info
"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
283 # normal, multi-format video
284 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
285 'md5': '26624b4e2523051b550067d547615906',
287 'id': 'be9867c9416c19f54a4a',
288 'display_id': 'experienced-milf-amazing-handjob',
290 'title': 'Experienced MILF Amazing Handjob',
291 'description': 'Experienced MILF giving an Amazing Handjob',
292 'thumbnail': r're:https?://.*\.jpg$',
294 'uploader': 'darvinfred06',
296 'comment_count': int,
297 'average_rating': float,
298 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
301 # quirky single-format case where the extension is given as fid, but the video is really an flv
302 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
303 'md5': 'fa56683e291fc80635907168a743c9ad',
305 'id': 'e5da0d3edce5404418f5',
306 'display_id': 'jeune-couple-russe',
308 'title': 'Jeune Couple Russe',
309 'description': 'Amateur',
310 'thumbnail': r're:https?://.*\.jpg$',
312 'uploader': 'whiskeyjar',
314 'comment_count': int,
315 'average_rating': float,
316 'categories': ['Amateur', 'Teen'],