]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/mofosex.py
66a098c9766441e9853fa5202e914f97e91ad93f
[yt-dlp.git] / yt_dlp / extractor / mofosex.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 int_or_none,
6 str_to_int,
7 unified_strdate,
8 )
9 from .keezmovies import KeezMoviesIE
10
11
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',
16 'md5': '558fcdafbb63a87c019218d6e49daf8a',
17 'info_dict': {
18 'id': '318131',
19 'display_id': 'amateur-teen-playing-and-masturbating-318131',
20 'ext': 'mp4',
21 'title': 'amateur teen playing and masturbating',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'upload_date': '20121114',
24 'view_count': int,
25 'like_count': int,
26 'dislike_count': int,
27 'age_limit': 18,
28 }
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 }]
34
35 def _real_extract(self, url):
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
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)