]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tnaflix.py
49516abca690721a83dee5044bb2cdd6540d4a07
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')
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'), 'http:')
81 cfg_xml
= self
._download
_xml
(
82 cfg_url
, display_id
, 'Downloading metadata',
83 transform_source
=fix_xml_ampersands
)
87 def extract_video_url(vl
):
88 return re
.sub('speed=\d+', 'speed=', vl
.text
)
90 video_link
= cfg_xml
.find('./videoLink')
91 if video_link
is not None:
93 'url': extract_video_url(video_link
),
94 'ext': xpath_text(cfg_xml
, './videoConfig/type', 'type', default
='flv'),
97 for item
in cfg_xml
.findall('./quality/item'):
98 video_link
= item
.find('./videoLink')
99 if video_link
is None:
101 res
= item
.find('res')
102 format_id
= None if res
is None else res
.text
103 height
= int_or_none(self
._search
_regex
(
104 r
'^(\d+)[pP]', format_id
, 'height', default
=None))
106 'url': self
._proto
_relative
_url
(extract_video_url(video_link
), 'http:'),
107 'format_id': format_id
,
111 self
._sort
_formats
(formats
)
113 thumbnail
= self
._proto
_relative
_url
(
114 xpath_text(cfg_xml
, './startThumb', 'thumbnail'), 'http:')
115 thumbnails
= self
._extract
_thumbnails
(cfg_xml
)
117 title
= self
._html
_search
_regex
(
118 self
._TITLE
_REGEX
, webpage
, 'title') if self
._TITLE
_REGEX
else self
._og
_search
_title
(webpage
)
120 age_limit
= self
._rta
_search
(webpage
)
122 duration
= parse_duration(self
._html
_search
_meta
(
123 'duration', webpage
, 'duration', default
=None))
125 def extract_field(pattern
, name
):
126 return self
._html
_search
_regex
(pattern
, webpage
, name
, default
=None) if pattern
else None
128 description
= extract_field(self
._DESCRIPTION
_REGEX
, 'description')
129 uploader
= extract_field(self
._UPLOADER
_REGEX
, 'uploader')
130 view_count
= str_to_int(extract_field(self
._VIEW
_COUNT
_REGEX
, 'view count'))
131 comment_count
= str_to_int(extract_field(self
._COMMENT
_COUNT
_REGEX
, 'comment count'))
132 average_rating
= float_or_none(extract_field(self
._AVERAGE
_RATING
_REGEX
, 'average rating'))
134 categories_str
= extract_field(self
._CATEGORIES
_REGEX
, 'categories')
135 categories
= categories_str
.split(', ') if categories_str
is not None else []
139 'display_id': display_id
,
141 'description': description
,
142 'thumbnail': thumbnail
,
143 'thumbnails': thumbnails
,
144 'duration': duration
,
145 'age_limit': age_limit
,
146 'uploader': uploader
,
147 'view_count': view_count
,
148 'comment_count': comment_count
,
149 'average_rating': average_rating
,
150 'categories': categories
,
155 class TNAFlixIE(TNAFlixNetworkBaseIE
):
156 _VALID_URL
= r
'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
158 _TITLE_REGEX
= r
'<title>(.+?) - TNAFlix Porn Videos</title>'
159 _DESCRIPTION_REGEX
= r
'<h3 itemprop="description">([^<]+)</h3>'
160 _UPLOADER_REGEX
= r
'(?s)<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)<div'
163 # anonymous uploader, no categories
164 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
165 'md5': 'ecf3498417d09216374fc5907f9c6ec0',
168 'display_id': 'Carmella-Decesare-striptease',
170 'title': 'Carmella Decesare - striptease',
171 'thumbnail': 're:https?://.*\.jpg$',
174 'uploader': 'Anonymous',
178 # non-anonymous uploader, categories
179 'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
180 'md5': '0f5d4d490dbfd117b8607054248a07c0',
183 'display_id': 'Educational-xxx-video',
185 'title': 'Educational xxx video',
186 'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
187 'thumbnail': 're:https?://.*\.jpg$',
190 'uploader': 'bobwhite39',
191 'categories': ['Amateur Porn', 'Squirting Videos', 'Teen Girls 18+'],
194 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
195 'only_matching': True,
199 class EMPFlixIE(TNAFlixNetworkBaseIE
):
200 _VALID_URL
= r
'https?://(?:www\.)?empflix\.com/videos/(?P<display_id>.+?)-(?P<id>[0-9]+)\.html'
202 _UPLOADER_REGEX
= r
'<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)</li>'
205 'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
206 'md5': 'b1bc15b6412d33902d6e5952035fcabc',
209 'display_id': 'Amateur-Finger-Fuck',
211 'title': 'Amateur Finger Fuck',
212 'description': 'Amateur solo finger fucking.',
213 'thumbnail': 're:https?://.*\.jpg$',
216 'uploader': 'cwbike',
217 'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
220 'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
221 'only_matching': True,
225 class MovieFapIE(TNAFlixNetworkBaseIE
):
226 _VALID_URL
= r
'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
228 _VIEW_COUNT_REGEX
= r
'<br>Views\s*<strong>([\d,.]+)</strong>'
229 _COMMENT_COUNT_REGEX
= r
'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
230 _AVERAGE_RATING_REGEX
= r
'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
231 _CATEGORIES_REGEX
= r
'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
234 # normal, multi-format video
235 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
236 'md5': '26624b4e2523051b550067d547615906',
238 'id': 'be9867c9416c19f54a4a',
239 'display_id': 'experienced-milf-amazing-handjob',
241 'title': 'Experienced MILF Amazing Handjob',
242 'description': 'Experienced MILF giving an Amazing Handjob',
243 'thumbnail': 're:https?://.*\.jpg$',
245 'uploader': 'darvinfred06',
247 'comment_count': int,
248 'average_rating': float,
249 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
252 # quirky single-format case where the extension is given as fid, but the video is really an flv
253 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
254 'md5': 'fa56683e291fc80635907168a743c9ad',
256 'id': 'e5da0d3edce5404418f5',
257 'display_id': 'jeune-couple-russe',
259 'title': 'Jeune Couple Russe',
260 'description': 'Amateur',
261 'thumbnail': 're:https?://.*\.jpg$',
263 'uploader': 'whiskeyjar',
265 'comment_count': int,
266 'average_rating': float,
267 'categories': ['Amateur', 'Teen'],