]>
Commit | Line | Data |
---|---|---|
a69969ee TJ |
1 | from __future__ import unicode_literals |
2 | ||
3 | import datetime | |
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
78ff59d0 | 7 | from ..utils import ( |
5c0a5718 | 8 | ExtractorError, |
8efd06aa | 9 | str_to_int, |
78ff59d0 PP |
10 | unified_strdate, |
11 | ) | |
a69969ee TJ |
12 | |
13 | ||
14 | class MotherlessIE(InfoExtractor): | |
5886b38d | 15 | _VALID_URL = r'https?://(?:www\.)?motherless\.com/(?:g/[a-z0-9_]+/)?(?P<id>[A-Z0-9]+)' |
d0459c53 S |
16 | _TESTS = [{ |
17 | 'url': 'http://motherless.com/AC3FFE1', | |
18 | 'md5': '310f62e325a9fafe64f68c0bccb6e75f', | |
19 | 'info_dict': { | |
20 | 'id': 'AC3FFE1', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Fucked in the ass while playing PS3', | |
23 | 'categories': ['Gaming', 'anal', 'reluctant', 'rough', 'Wife'], | |
24 | 'upload_date': '20100913', | |
25 | 'uploader_id': 'famouslyfuckedup', | |
ec85ded8 | 26 | 'thumbnail': r're:http://.*\.jpg', |
d0459c53 S |
27 | 'age_limit': 18, |
28 | } | |
29 | }, { | |
30 | 'url': 'http://motherless.com/532291B', | |
31 | 'md5': 'bc59a6b47d1f958e61fbd38a4d31b131', | |
32 | 'info_dict': { | |
33 | 'id': '532291B', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Amazing girl playing the omegle game, PERFECT!', | |
36 | 'categories': ['Amateur', 'webcam', 'omegle', 'pink', 'young', 'masturbate', 'teen', | |
37 | 'game', 'hairy'], | |
38 | 'upload_date': '20140622', | |
39 | 'uploader_id': 'Sulivana7x', | |
ec85ded8 | 40 | 'thumbnail': r're:http://.*\.jpg', |
d0459c53 | 41 | 'age_limit': 18, |
43479d9e | 42 | }, |
d0459c53 S |
43 | 'skip': '404', |
44 | }, { | |
45 | 'url': 'http://motherless.com/g/cosplay/633979F', | |
46 | 'md5': '0b2a43f447a49c3e649c93ad1fafa4a0', | |
47 | 'info_dict': { | |
48 | 'id': '633979F', | |
49 | 'ext': 'mp4', | |
50 | 'title': 'Turtlette', | |
51 | 'categories': ['superheroine heroine superher'], | |
52 | 'upload_date': '20140827', | |
53 | 'uploader_id': 'shade0230', | |
ec85ded8 | 54 | 'thumbnail': r're:http://.*\.jpg', |
d0459c53 | 55 | 'age_limit': 18, |
a69969ee | 56 | } |
d0459c53 S |
57 | }, { |
58 | # no keywords | |
59 | 'url': 'http://motherless.com/8B4BBC1', | |
60 | 'only_matching': True, | |
61 | }] | |
a69969ee | 62 | |
8efd06aa PH |
63 | def _real_extract(self, url): |
64 | video_id = self._match_id(url) | |
a69969ee TJ |
65 | webpage = self._download_webpage(url, video_id) |
66 | ||
5c0a5718 S |
67 | if any(p in webpage for p in ( |
68 | '<title>404 - MOTHERLESS.COM<', | |
69 | ">The page you're looking for cannot be found.<")): | |
70 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) | |
71 | ||
ff5873b7 S |
72 | if '>The content you are trying to view is for friends only.' in webpage: |
73 | raise ExtractorError('Video %s is for friends only' % video_id, expected=True) | |
74 | ||
8efd06aa PH |
75 | title = self._html_search_regex( |
76 | r'id="view-upload-title">\s+([^<]+)<', webpage, 'title') | |
77 | video_url = self._html_search_regex( | |
78 | r'setup\(\{\s+"file".+: "([^"]+)",', webpage, 'video URL') | |
78ff59d0 | 79 | age_limit = self._rta_search(webpage) |
8efd06aa PH |
80 | view_count = str_to_int(self._html_search_regex( |
81 | r'<strong>Views</strong>\s+([^<]+)<', | |
82 | webpage, 'view count', fatal=False)) | |
83 | like_count = str_to_int(self._html_search_regex( | |
84 | r'<strong>Favorited</strong>\s+([^<]+)<', | |
85 | webpage, 'like count', fatal=False)) | |
5f6a1245 | 86 | |
8efd06aa PH |
87 | upload_date = self._html_search_regex( |
88 | r'<strong>Uploaded</strong>\s+([^<]+)<', webpage, 'upload date') | |
78ff59d0 PP |
89 | if 'Ago' in upload_date: |
90 | days = int(re.search(r'([0-9]+)', upload_date).group(1)) | |
91 | upload_date = (datetime.datetime.now() - datetime.timedelta(days=days)).strftime('%Y%m%d') | |
92 | else: | |
93 | upload_date = unified_strdate(upload_date) | |
94 | ||
a69969ee | 95 | comment_count = webpage.count('class="media-comment-contents"') |
8efd06aa PH |
96 | uploader_id = self._html_search_regex( |
97 | r'"thumb-member-username">\s+<a href="/m/([^"]+)"', | |
98 | webpage, 'uploader_id') | |
a69969ee | 99 | |
43479d9e | 100 | categories = self._html_search_meta('keywords', webpage, default=None) |
78ff59d0 | 101 | if categories: |
a69969ee TJ |
102 | categories = [cat.strip() for cat in categories.split(',')] |
103 | ||
a69969ee TJ |
104 | return { |
105 | 'id': video_id, | |
106 | 'title': title, | |
107 | 'upload_date': upload_date, | |
108 | 'uploader_id': uploader_id, | |
78ff59d0 | 109 | 'thumbnail': self._og_search_thumbnail(webpage), |
a69969ee | 110 | 'categories': categories, |
8efd06aa PH |
111 | 'view_count': view_count, |
112 | 'like_count': like_count, | |
a69969ee TJ |
113 | 'comment_count': comment_count, |
114 | 'age_limit': age_limit, | |
115 | 'url': video_url, | |
116 | } |