]>
Commit | Line | Data |
---|---|---|
a69969ee TJ |
1 | import datetime |
2 | import re | |
f2ff0f6f | 3 | import urllib.parse |
a69969ee TJ |
4 | |
5 | from .common import InfoExtractor | |
78ff59d0 | 6 | from ..utils import ( |
5c0a5718 | 7 | ExtractorError, |
f2ff0f6f | 8 | OnDemandPagedList, |
9 | remove_end, | |
8efd06aa | 10 | str_to_int, |
78ff59d0 PP |
11 | unified_strdate, |
12 | ) | |
a69969ee TJ |
13 | |
14 | ||
15 | class MotherlessIE(InfoExtractor): | |
f2ff0f6f | 16 | _VALID_URL = r'https?://(?:www\.)?motherless\.com/(?:g/[a-z0-9_]+/|G[VIG]?[A-F0-9]+/)?(?P<id>[A-F0-9]+)' |
d0459c53 | 17 | _TESTS = [{ |
f2ff0f6f | 18 | 'url': 'http://motherless.com/EE97006', |
19 | 'md5': 'cb5e7438f7a3c4e886b7bccc1292a3bc', | |
d0459c53 | 20 | 'info_dict': { |
f2ff0f6f | 21 | 'id': 'EE97006', |
d0459c53 | 22 | 'ext': 'mp4', |
f2ff0f6f | 23 | 'title': 'Dogging blond Brit getting glazed (comp)', |
24 | 'categories': ['UK', 'slag', 'whore', 'dogging', 'cunt', 'cumhound', 'big tits', 'Pearl Necklace'], | |
25 | 'upload_date': '20230519', | |
26 | 'uploader_id': 'deathbird', | |
dcc8522f | 27 | 'thumbnail': r're:https?://.*\.jpg', |
d0459c53 | 28 | 'age_limit': 18, |
f2ff0f6f | 29 | 'comment_count': int, |
30 | 'view_count': int, | |
31 | 'like_count': int, | |
32 | }, | |
33 | 'params': { | |
34 | # Incomplete cert chains | |
35 | 'nocheckcertificate': True, | |
36 | }, | |
d0459c53 S |
37 | }, { |
38 | 'url': 'http://motherless.com/532291B', | |
39 | 'md5': 'bc59a6b47d1f958e61fbd38a4d31b131', | |
40 | 'info_dict': { | |
41 | 'id': '532291B', | |
42 | 'ext': 'mp4', | |
43 | 'title': 'Amazing girl playing the omegle game, PERFECT!', | |
44 | 'categories': ['Amateur', 'webcam', 'omegle', 'pink', 'young', 'masturbate', 'teen', | |
45 | 'game', 'hairy'], | |
46 | 'upload_date': '20140622', | |
47 | 'uploader_id': 'Sulivana7x', | |
dcc8522f | 48 | 'thumbnail': r're:https?://.*\.jpg', |
d0459c53 | 49 | 'age_limit': 18, |
43479d9e | 50 | }, |
d0459c53 S |
51 | 'skip': '404', |
52 | }, { | |
53 | 'url': 'http://motherless.com/g/cosplay/633979F', | |
54 | 'md5': '0b2a43f447a49c3e649c93ad1fafa4a0', | |
55 | 'info_dict': { | |
56 | 'id': '633979F', | |
57 | 'ext': 'mp4', | |
58 | 'title': 'Turtlette', | |
f2ff0f6f | 59 | 'categories': ['superheroine heroine superher'], |
d0459c53 S |
60 | 'upload_date': '20140827', |
61 | 'uploader_id': 'shade0230', | |
dcc8522f | 62 | 'thumbnail': r're:https?://.*\.jpg', |
d0459c53 | 63 | 'age_limit': 18, |
f2ff0f6f | 64 | 'like_count': int, |
65 | 'comment_count': int, | |
66 | 'view_count': int, | |
67 | }, | |
68 | 'params': { | |
69 | 'nocheckcertificate': True, | |
70 | }, | |
d0459c53 | 71 | }, { |
d0459c53 | 72 | 'url': 'http://motherless.com/8B4BBC1', |
f2ff0f6f | 73 | 'info_dict': { |
74 | 'id': '8B4BBC1', | |
75 | 'ext': 'mp4', | |
76 | 'title': 'VIDEO00441.mp4', | |
77 | 'categories': [], | |
78 | 'upload_date': '20160214', | |
79 | 'uploader_id': 'NMWildGirl', | |
80 | 'thumbnail': r're:https?://.*\.jpg', | |
81 | 'age_limit': 18, | |
82 | 'like_count': int, | |
83 | 'comment_count': int, | |
84 | 'view_count': int, | |
85 | }, | |
86 | 'params': { | |
87 | 'nocheckcertificate': True, | |
88 | }, | |
00dd0cd5 | 89 | }, { |
90 | # see https://motherless.com/videos/recent for recent videos with | |
91 | # uploaded date in "ago" format | |
92 | 'url': 'https://motherless.com/3C3E2CF', | |
93 | 'info_dict': { | |
94 | 'id': '3C3E2CF', | |
95 | 'ext': 'mp4', | |
96 | 'title': 'a/ Hot Teens', | |
97 | 'categories': list, | |
98 | 'upload_date': '20210104', | |
db4678e4 | 99 | 'uploader_id': 'anonymous', |
00dd0cd5 | 100 | 'thumbnail': r're:https?://.*\.jpg', |
101 | 'age_limit': 18, | |
f2ff0f6f | 102 | 'like_count': int, |
103 | 'comment_count': int, | |
104 | 'view_count': int, | |
00dd0cd5 | 105 | }, |
106 | 'params': { | |
f2ff0f6f | 107 | 'nocheckcertificate': True, |
00dd0cd5 | 108 | }, |
d0459c53 | 109 | }] |
a69969ee | 110 | |
8efd06aa PH |
111 | def _real_extract(self, url): |
112 | video_id = self._match_id(url) | |
a69969ee TJ |
113 | webpage = self._download_webpage(url, video_id) |
114 | ||
5c0a5718 S |
115 | if any(p in webpage for p in ( |
116 | '<title>404 - MOTHERLESS.COM<', | |
117 | ">The page you're looking for cannot be found.<")): | |
118 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) | |
119 | ||
ff5873b7 S |
120 | if '>The content you are trying to view is for friends only.' in webpage: |
121 | raise ExtractorError('Video %s is for friends only' % video_id, expected=True) | |
122 | ||
8efd06aa | 123 | title = self._html_search_regex( |
dcc8522f S |
124 | (r'(?s)<div[^>]+\bclass=["\']media-meta-title[^>]+>(.+?)</div>', |
125 | r'id="view-upload-title">\s+([^<]+)<'), webpage, 'title') | |
b71cc719 S |
126 | video_url = (self._html_search_regex( |
127 | (r'setup\(\{\s*["\']file["\']\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', | |
128 | r'fileurl\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1'), | |
3089bc74 S |
129 | webpage, 'video URL', default=None, group='url') |
130 | or 'http://cdn4.videos.motherlessmedia.com/videos/%s.mp4?fs=opencloud' % video_id) | |
78ff59d0 | 131 | age_limit = self._rta_search(webpage) |
8efd06aa | 132 | view_count = str_to_int(self._html_search_regex( |
00dd0cd5 | 133 | (r'>([\d,.]+)\s+Views<', r'<strong>Views</strong>\s+([^<]+)<'), |
8efd06aa PH |
134 | webpage, 'view count', fatal=False)) |
135 | like_count = str_to_int(self._html_search_regex( | |
00dd0cd5 | 136 | (r'>([\d,.]+)\s+Favorites<', |
137 | r'<strong>Favorited</strong>\s+([^<]+)<'), | |
8efd06aa | 138 | webpage, 'like count', fatal=False)) |
5f6a1245 | 139 | |
00dd0cd5 | 140 | upload_date = unified_strdate(self._search_regex( |
141 | r'class=["\']count[^>]+>(\d+\s+[a-zA-Z]{3}\s+\d{4})<', webpage, | |
142 | 'upload date', default=None)) | |
143 | if not upload_date: | |
144 | uploaded_ago = self._search_regex( | |
145 | r'>\s*(\d+[hd])\s+[aA]go\b', webpage, 'uploaded ago', | |
146 | default=None) | |
147 | if uploaded_ago: | |
148 | delta = int(uploaded_ago[:-1]) | |
149 | _AGO_UNITS = { | |
150 | 'h': 'hours', | |
151 | 'd': 'days', | |
152 | } | |
153 | kwargs = {_AGO_UNITS.get(uploaded_ago[-1]): delta} | |
154 | upload_date = (datetime.datetime.utcnow() - datetime.timedelta(**kwargs)).strftime('%Y%m%d') | |
78ff59d0 | 155 | |
db4678e4 | 156 | comment_count = len(re.findall(r'''class\s*=\s*['"]media-comment-contents\b''', webpage)) |
8efd06aa | 157 | uploader_id = self._html_search_regex( |
db4678e4 | 158 | (r'''<span\b[^>]+\bclass\s*=\s*["']username\b[^>]*>([^<]+)</span>''', |
159 | r'''(?s)['"](?:media-meta-member|thumb-member-username)\b[^>]+>\s*<a\b[^>]+\bhref\s*=\s*['"]/m/([^"']+)'''), | |
419508ea | 160 | webpage, 'uploader_id', fatal=False) |
f2ff0f6f | 161 | categories = self._html_search_meta('keywords', webpage, default='') |
162 | categories = [cat.strip() for cat in categories.split(',') if cat.strip()] | |
a69969ee | 163 | |
a69969ee TJ |
164 | return { |
165 | 'id': video_id, | |
166 | 'title': title, | |
167 | 'upload_date': upload_date, | |
168 | 'uploader_id': uploader_id, | |
78ff59d0 | 169 | 'thumbnail': self._og_search_thumbnail(webpage), |
a69969ee | 170 | 'categories': categories, |
8efd06aa PH |
171 | 'view_count': view_count, |
172 | 'like_count': like_count, | |
a69969ee TJ |
173 | 'comment_count': comment_count, |
174 | 'age_limit': age_limit, | |
175 | 'url': video_url, | |
176 | } | |
45283afd MW |
177 | |
178 | ||
f2ff0f6f | 179 | class MotherlessPaginatedIE(InfoExtractor): |
180 | _PAGE_SIZE = 60 | |
181 | ||
182 | def _correct_path(self, url, item_id): | |
183 | raise NotImplementedError('This method must be implemented by subclasses') | |
184 | ||
185 | def _extract_entries(self, webpage, base): | |
186 | for mobj in re.finditer(r'href="[^"]*(?P<href>/[A-F0-9]+)"\s+title="(?P<title>[^"]+)', | |
187 | webpage): | |
188 | video_url = urllib.parse.urljoin(base, mobj.group('href')) | |
189 | video_id = MotherlessIE.get_temp_id(video_url) | |
190 | ||
191 | if video_id: | |
192 | yield self.url_result(video_url, MotherlessIE, video_id, mobj.group('title')) | |
193 | ||
194 | def _real_extract(self, url): | |
195 | item_id = self._match_id(url) | |
196 | real_url = self._correct_path(url, item_id) | |
197 | webpage = self._download_webpage(real_url, item_id, 'Downloading page 1') | |
198 | ||
199 | def get_page(idx): | |
200 | page = idx + 1 | |
201 | current_page = webpage if not idx else self._download_webpage( | |
202 | real_url, item_id, note=f'Downloading page {page}', query={'page': page}) | |
203 | yield from self._extract_entries(current_page, real_url) | |
204 | ||
205 | return self.playlist_result( | |
206 | OnDemandPagedList(get_page, self._PAGE_SIZE), item_id, | |
207 | remove_end(self._html_extract_title(webpage), ' | MOTHERLESS.COM ™')) | |
208 | ||
209 | ||
210 | class MotherlessGroupIE(MotherlessPaginatedIE): | |
211 | _VALID_URL = r'https?://(?:www\.)?motherless\.com/g[vifm]?/(?P<id>[a-z0-9_]+)/?(?:$|[#?])' | |
45283afd | 212 | _TESTS = [{ |
f2ff0f6f | 213 | 'url': 'http://motherless.com/gv/movie_scenes', |
45283afd MW |
214 | 'info_dict': { |
215 | 'id': 'movie_scenes', | |
216 | 'title': 'Movie Scenes', | |
45283afd | 217 | }, |
f2ff0f6f | 218 | 'playlist_mincount': 540, |
45283afd | 219 | }, { |
f2ff0f6f | 220 | 'url': 'http://motherless.com/g/sex_must_be_funny', |
45283afd MW |
221 | 'info_dict': { |
222 | 'id': 'sex_must_be_funny', | |
223 | 'title': 'Sex must be funny', | |
45283afd | 224 | }, |
f2ff0f6f | 225 | 'playlist_count': 0, |
419508ea | 226 | }, { |
f2ff0f6f | 227 | 'url': 'https://motherless.com/gv/beautiful_cock', |
419508ea | 228 | 'info_dict': { |
229 | 'id': 'beautiful_cock', | |
230 | 'title': 'Beautiful Cock', | |
419508ea | 231 | }, |
f2ff0f6f | 232 | 'playlist_mincount': 2040, |
45283afd MW |
233 | }] |
234 | ||
f2ff0f6f | 235 | def _correct_path(self, url, item_id): |
236 | return urllib.parse.urljoin(url, f'/gv/{item_id}') | |
45283afd | 237 | |
45283afd | 238 | |
f2ff0f6f | 239 | class MotherlessGalleryIE(MotherlessPaginatedIE): |
240 | _VALID_URL = r'https?://(?:www\.)?motherless\.com/G[VIG]?(?P<id>[A-F0-9]+)/?(?:$|[#?])' | |
241 | _TESTS = [{ | |
242 | 'url': 'https://motherless.com/GV338999F', | |
243 | 'info_dict': { | |
244 | 'id': '338999F', | |
245 | 'title': 'Random', | |
246 | }, | |
247 | 'playlist_mincount': 190, | |
248 | }, { | |
249 | 'url': 'https://motherless.com/GVABD6213', | |
250 | 'info_dict': { | |
251 | 'id': 'ABD6213', | |
252 | 'title': 'Cuties', | |
253 | }, | |
254 | 'playlist_mincount': 2, | |
255 | }, { | |
256 | 'url': 'https://motherless.com/GVBCF7622', | |
257 | 'info_dict': { | |
258 | 'id': 'BCF7622', | |
259 | 'title': 'Vintage', | |
260 | }, | |
261 | 'playlist_count': 0, | |
262 | }, { | |
263 | 'url': 'https://motherless.com/G035DE2F', | |
264 | 'info_dict': { | |
265 | 'id': '035DE2F', | |
266 | 'title': 'General', | |
267 | }, | |
268 | 'playlist_mincount': 420, | |
269 | }] | |
45283afd | 270 | |
f2ff0f6f | 271 | def _correct_path(self, url, item_id): |
272 | return urllib.parse.urljoin(url, f'/GV{item_id}') |