]>
Commit | Line | Data |
---|---|---|
4e7b5bba S |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
6be17c08 S |
4 | from ..utils import ( |
5 | int_or_none, | |
6 | str_to_int, | |
7 | unified_strdate, | |
77ae6587 | 8 | ) |
6be17c08 | 9 | from .keezmovies import KeezMoviesIE |
77ae6587 | 10 | |
191b7cbb | 11 | |
6be17c08 S |
12 | class MofosexIE(KeezMoviesIE): |
13 | _VALID_URL = r'https?://(?:www\.)?mofosex\.com/videos/(?P<id>\d+)/(?P<display_id>[^/?#&.]+)\.html' | |
14 | _TESTS = [{ | |
15 | 'url': 'http://www.mofosex.com/videos/318131/amateur-teen-playing-and-masturbating-318131.html', | |
c1942002 | 16 | 'md5': '558fcdafbb63a87c019218d6e49daf8a', |
191b7cbb | 17 | 'info_dict': { |
6be17c08 S |
18 | 'id': '318131', |
19 | 'display_id': 'amateur-teen-playing-and-masturbating-318131', | |
191b7cbb | 20 | 'ext': 'mp4', |
6be17c08 | 21 | 'title': 'amateur teen playing and masturbating', |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
6be17c08 S |
23 | 'upload_date': '20121114', |
24 | 'view_count': int, | |
25 | 'like_count': int, | |
26 | 'dislike_count': int, | |
191b7cbb | 27 | 'age_limit': 18, |
77ae6587 | 28 | } |
6be17c08 S |
29 | }, { |
30 | # This video is no longer available | |
31 | 'url': 'http://www.mofosex.com/videos/5018/japanese-teen-music-video.html', | |
32 | 'only_matching': True, | |
33 | }] | |
77ae6587 | 34 | |
35 | def _real_extract(self, url): | |
6be17c08 S |
36 | webpage, info = self._extract_info(url) |
37 | ||
38 | view_count = str_to_int(self._search_regex( | |
39 | r'VIEWS:</span>\s*([\d,.]+)', webpage, 'view count', fatal=False)) | |
40 | like_count = int_or_none(self._search_regex( | |
41 | r'id=["\']amountLikes["\'][^>]*>(\d+)', webpage, | |
42 | 'like count', fatal=False)) | |
43 | dislike_count = int_or_none(self._search_regex( | |
44 | r'id=["\']amountDislikes["\'][^>]*>(\d+)', webpage, | |
45 | 'like count', fatal=False)) | |
46 | upload_date = unified_strdate(self._html_search_regex( | |
47 | r'Added:</span>([^<]+)', webpage, 'upload date', fatal=False)) | |
48 | ||
49 | info.update({ | |
50 | 'view_count': view_count, | |
51 | 'like_count': like_count, | |
52 | 'dislike_count': dislike_count, | |
53 | 'upload_date': upload_date, | |
54 | 'thumbnail': self._og_search_thumbnail(webpage), | |
55 | }) | |
56 | ||
57 | return info | |
4e7b5bba S |
58 | |
59 | ||
60 | class MofosexEmbedIE(InfoExtractor): | |
61 | _VALID_URL = r'https?://(?:www\.)?mofosex\.com/embed/?\?.*?\bvideoid=(?P<id>\d+)' | |
62 | _TESTS = [{ | |
63 | 'url': 'https://www.mofosex.com/embed/?videoid=318131&referrer=KM', | |
64 | 'only_matching': True, | |
65 | }] | |
66 | ||
67 | @staticmethod | |
68 | def _extract_urls(webpage): | |
69 | return re.findall( | |
70 | r'<iframe[^>]+\bsrc=["\']((?:https?:)?//(?:www\.)?mofosex\.com/embed/?\?.*?\bvideoid=\d+)', | |
71 | webpage) | |
72 | ||
73 | def _real_extract(self, url): | |
74 | video_id = self._match_id(url) | |
75 | return self.url_result( | |
76 | 'http://www.mofosex.com/videos/{0}/{0}.html'.format(video_id), | |
77 | ie=MofosexIE.ie_key(), video_id=video_id) |