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