]>
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
17 class TNAFlixNetworkBaseIE(InfoExtractor
):
18 # May be overridden in descendants if necessary
20 r
'flashvars\.config\s*=\s*escape\("([^"]+)"',
21 r
'<input[^>]+name="config\d?" value="([^"]+)"',
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
= re
.match(self
._VALID
_URL
, url
)
73 video_id
= mobj
.group('id')
74 display_id
= mobj
.group('display_id') if 'display_id' in mobj
.groupdict() else video_id
76 webpage
= self
._download
_webpage
(url
, display_id
)
78 cfg_url
= self
._proto
_relative
_url
(self
._html
_search
_regex
(
79 self
._CONFIG
_REGEX
, webpage
, 'flashvars.config', default
=None), 'http:')
82 inputs
= self
._hidden
_inputs
(webpage
)
83 cfg_url
= 'https://cdn-fck.tnaflix.com/tnaflix/%s.fid?key=%s' % (inputs
['vkey'], inputs
['nkey'])
85 cfg_xml
= self
._download
_xml
(
86 cfg_url
, display_id
, 'Downloading metadata',
87 transform_source
=fix_xml_ampersands
)
91 def extract_video_url(vl
):
92 return re
.sub('speed=\d+', 'speed=', vl
.text
)
94 video_link
= cfg_xml
.find('./videoLink')
95 if video_link
is not None:
97 'url': extract_video_url(video_link
),
98 'ext': xpath_text(cfg_xml
, './videoConfig/type', 'type', default
='flv'),
101 for item
in cfg_xml
.findall('./quality/item'):
102 video_link
= item
.find('./videoLink')
103 if video_link
is None:
105 res
= item
.find('res')
106 format_id
= None if res
is None else res
.text
107 height
= int_or_none(self
._search
_regex
(
108 r
'^(\d+)[pP]', format_id
, 'height', default
=None))
110 'url': self
._proto
_relative
_url
(extract_video_url(video_link
), 'http:'),
111 'format_id': format_id
,
115 self
._sort
_formats
(formats
)
117 thumbnail
= self
._proto
_relative
_url
(
118 xpath_text(cfg_xml
, './startThumb', 'thumbnail'), 'http:')
119 thumbnails
= self
._extract
_thumbnails
(cfg_xml
)
121 title
= self
._html
_search
_regex
(
122 self
._TITLE
_REGEX
, webpage
, 'title') if self
._TITLE
_REGEX
else self
._og
_search
_title
(webpage
)
124 age_limit
= self
._rta
_search
(webpage
) or 18
126 duration
= parse_duration(self
._html
_search
_meta
(
127 'duration', webpage
, 'duration', default
=None))
129 def extract_field(pattern
, name
):
130 return self
._html
_search
_regex
(pattern
, webpage
, name
, default
=None) if pattern
else None
132 description
= extract_field(self
._DESCRIPTION
_REGEX
, 'description')
133 uploader
= extract_field(self
._UPLOADER
_REGEX
, 'uploader')
134 view_count
= str_to_int(extract_field(self
._VIEW
_COUNT
_REGEX
, 'view count'))
135 comment_count
= str_to_int(extract_field(self
._COMMENT
_COUNT
_REGEX
, 'comment count'))
136 average_rating
= float_or_none(extract_field(self
._AVERAGE
_RATING
_REGEX
, 'average rating'))
138 categories_str
= extract_field(self
._CATEGORIES
_REGEX
, 'categories')
139 categories
= [c
.strip() for c
in categories_str
.split(',')] if categories_str
is not None else []
143 'display_id': display_id
,
145 'description': description
,
146 'thumbnail': thumbnail
,
147 'thumbnails': thumbnails
,
148 'duration': duration
,
149 'age_limit': age_limit
,
150 'uploader': uploader
,
151 'view_count': view_count
,
152 'comment_count': comment_count
,
153 'average_rating': average_rating
,
154 'categories': categories
,
159 class TNAFlixNetworkEmbedIE(TNAFlixNetworkBaseIE
):
160 _VALID_URL
= r
'https?://player\.(?:tna|emp)flix\.com/video/(?P<id>\d+)'
162 _TITLE_REGEX
= r
'<title>([^<]+)</title>'
165 'url': 'https://player.tnaflix.com/video/6538',
168 'display_id': '6538',
170 'title': 'Educational xxx video',
171 'thumbnail': 're:https?://.*\.jpg$',
175 'skip_download': True,
178 'url': 'https://player.empflix.com/video/33051',
179 'only_matching': True,
183 def _extract_urls(webpage
):
184 return [url
for _
, url
in re
.findall(
185 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.(?
:tna|emp
)flix\
.com
/video
/\d
+)\
1',
189 class TNAFlixIE(TNAFlixNetworkBaseIE):
190 _VALID_URL = r'https?
://(?
:www\
.)?tnaflix\
.com
/[^
/]+/(?P
<display_id
>[^
/]+)/video(?P
<id>\d
+)'
192 _TITLE_REGEX = r'<title
>(.+?
) - TNAFlix Porn Videos
</title
>'
193 _DESCRIPTION_REGEX = r'<meta
[^
>]+name
="description"[^
>]+content
="([^"]+)"'
194 _UPLOADER_REGEX = r'<i>\s*Verified Member\s*</i>\s*<h1>(.+?)</h1>'
195 _CATEGORIES_REGEX = r'(?s)<span[^>]*>Categories:</span>(.+?)</div>'
198 # anonymous uploader, no categories
199 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
200 'md5': '7e569419fe6d69543d01e6be22f5f7c4',
203 'display_id': 'Carmella-Decesare-striptease',
205 'title': 'Carmella Decesare - striptease',
206 'thumbnail': 're:https?://.*\.jpg$',
209 'categories': ['Porn Stars'],
212 # non-anonymous uploader, categories
213 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
214 'md5': 'fcba2636572895aba116171a899a5658',
217 'display_id': 'Educational-xxx-video',
219 'title': 'Educational xxx video',
220 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
221 'thumbnail': 're:https?://.*\.jpg$',
224 'uploader': 'bobwhite39',
225 'categories': ['Amateur Porn', 'Squirting Videos', 'Teen Girls 18+'],
228 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
229 'only_matching': True,
233 class EMPFlixIE(TNAFlixNetworkBaseIE):
234 _VALID_URL = r'https?://(?:www\.)?empflix\.com/videos/(?P<display_id>.+?)-(?P<id>[0-9]+)\.html'
236 _UPLOADER_REGEX = r'<span[^>]+class="infoTitle
"[^>]*>Uploaded By:</span>(.+?)</li>'
239 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
240 'md5': 'b1bc15b6412d33902d6e5952035fcabc',
243 'display_id': 'Amateur-Finger-Fuck',
245 'title': 'Amateur Finger Fuck',
246 'description': 'Amateur solo finger fucking.',
247 'thumbnail': 're:https?://.*\.jpg$',
250 'uploader': 'cwbike',
251 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
254 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
255 'only_matching': True,
259 class MovieFapIE(TNAFlixNetworkBaseIE):
260 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
262 _VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
263 _COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount
"[^>]*>([\d,.]+)</span>'
264 _AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
265 _CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info
"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
268 # normal, multi-format video
269 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
270 'md5': '26624b4e2523051b550067d547615906',
272 'id': 'be9867c9416c19f54a4a',
273 'display_id': 'experienced-milf-amazing-handjob',
275 'title': 'Experienced MILF Amazing Handjob',
276 'description': 'Experienced MILF giving an Amazing Handjob',
277 'thumbnail': 're:https?://.*\.jpg$',
279 'uploader': 'darvinfred06',
281 'comment_count': int,
282 'average_rating': float,
283 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
286 # quirky single-format case where the extension is given as fid, but the video is really an flv
287 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
288 'md5': 'fa56683e291fc80635907168a743c9ad',
290 'id': 'e5da0d3edce5404418f5',
291 'display_id': 'jeune-couple-russe',
293 'title': 'Jeune Couple Russe',
294 'description': 'Amateur',
295 'thumbnail': 're:https?://.*\.jpg$',
297 'uploader': 'whiskeyjar',
299 'comment_count': int,
300 'average_rating': float,
301 'categories': ['Amateur', 'Teen'],