]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tnaflix.py
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 TNAEMPFlixBaseIE(TNAFlixNetworkBaseIE):
205 _DESCRIPTION_REGEX = r'(?s
)>Description
:</[^
>]+>(.+?
)<'
206 _UPLOADER_REGEX = r'<span
>by\s
*<a
[^
>]+\bhref
=["\']/profile/[^>]+>([^<]+)<'
207 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
210 class TNAFlixIE(TNAEMPFlixBaseIE):
211 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
213 _TITLE_REGEX = r'<title>(.+?) - (?:TNAFlix Porn Videos|TNAFlix\.com)</title>'
216 # anonymous uploader, no categories
217 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
218 'md5': '7e569419fe6d69543d01e6be22f5f7c4',
221 'display_id': 'Carmella-Decesare-striptease',
223 'title': 'Carmella Decesare - striptease',
224 'thumbnail': r're:https?://.*\.jpg$',
227 'categories': ['Porn Stars'],
230 # non-anonymous uploader, categories
231 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
232 'md5': '0f5d4d490dbfd117b8607054248a07c0',
235 'display_id': 'Educational-xxx-video',
237 'title': 'Educational xxx video',
238 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
239 'thumbnail': r're:https?://.*\.jpg$',
242 'uploader': 'bobwhite39',
246 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
247 'only_matching': True,
251 class EMPFlixIE(TNAEMPFlixBaseIE):
252 _VALID_URL = r'https?://(?:www\.)?empflix\.com/(?:videos/(?P<display_id>.+?)-|[^/]+/(?P<display_id_2>[^/]+)/video)(?P<id>[0-9]+)'
258 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
259 'md5': 'bc30d48b91a7179448a0bda465114676',
262 'display_id': 'Amateur-Finger-Fuck',
264 'title': 'Amateur Finger Fuck',
265 'description': 'Amateur solo finger fucking.',
266 'thumbnail': r're:https?://.*\.jpg$',
269 'uploader': 'cwbike',
270 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
273 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
274 'only_matching': True,
276 'url': 'https://www.empflix.com/amateur-porn/Amateur-Finger-Fuck/video33051',
277 'only_matching': True,
281 class MovieFapIE(TNAFlixNetworkBaseIE):
282 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
284 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
285 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount
"[^>]*>([\d,.]+)</span>'
286 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
287 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info
"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
290 # normal, multi-format video
291 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
292 'md5': '26624b4e2523051b550067d547615906',
294 'id': 'be9867c9416c19f54a4a',
295 'display_id': 'experienced-milf-amazing-handjob',
297 'title': 'Experienced MILF Amazing Handjob',
298 'description': 'Experienced MILF giving an Amazing Handjob',
299 'thumbnail': r're:https?://.*\.jpg$',
301 'uploader': 'darvinfred06',
303 'comment_count': int,
304 'average_rating': float,
305 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
308 # quirky single-format case where the extension is given as fid, but the video is really an flv
309 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
310 'md5': 'fa56683e291fc80635907168a743c9ad',
312 'id': 'e5da0d3edce5404418f5',
313 'display_id': 'jeune-couple-russe',
315 'title': 'Jeune Couple Russe',
316 'description': 'Amateur',
317 'thumbnail': r're:https?://.*\.jpg$',
319 'uploader': 'whiskeyjar',
321 'comment_count': int,
322 'average_rating': float,
323 'categories': ['Amateur', 'Teen'],