]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mofosex.py
debian/control: Remove mplayer2 from recommends. (Closes: #841187)
[youtubedl] / youtube_dl / extractor / mofosex.py
1 from __future__ import unicode_literals
2
3 from ..utils import (
4 int_or_none,
5 str_to_int,
6 unified_strdate,
7 )
8 from .keezmovies import KeezMoviesIE
9
10
11 class MofosexIE(KeezMoviesIE):
12 _VALID_URL = r'https?://(?:www\.)?mofosex\.com/videos/(?P<id>\d+)/(?P<display_id>[^/?#&.]+)\.html'
13 _TESTS = [{
14 'url': 'http://www.mofosex.com/videos/318131/amateur-teen-playing-and-masturbating-318131.html',
15 'md5': '39a15853632b7b2e5679f92f69b78e91',
16 'info_dict': {
17 'id': '318131',
18 'display_id': 'amateur-teen-playing-and-masturbating-318131',
19 'ext': 'mp4',
20 'title': 'amateur teen playing and masturbating',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 'upload_date': '20121114',
23 'view_count': int,
24 'like_count': int,
25 'dislike_count': int,
26 'age_limit': 18,
27 }
28 }, {
29 # This video is no longer available
30 'url': 'http://www.mofosex.com/videos/5018/japanese-teen-music-video.html',
31 'only_matching': True,
32 }]
33
34 def _real_extract(self, url):
35 webpage, info = self._extract_info(url)
36
37 view_count = str_to_int(self._search_regex(
38 r'VIEWS:</span>\s*([\d,.]+)', webpage, 'view count', fatal=False))
39 like_count = int_or_none(self._search_regex(
40 r'id=["\']amountLikes["\'][^>]*>(\d+)', webpage,
41 'like count', fatal=False))
42 dislike_count = int_or_none(self._search_regex(
43 r'id=["\']amountDislikes["\'][^>]*>(\d+)', webpage,
44 'like count', fatal=False))
45 upload_date = unified_strdate(self._html_search_regex(
46 r'Added:</span>([^<]+)', webpage, 'upload date', fatal=False))
47
48 info.update({
49 'view_count': view_count,
50 'like_count': like_count,
51 'dislike_count': dislike_count,
52 'upload_date': upload_date,
53 'thumbnail': self._og_search_thumbnail(webpage),
54 })
55
56 return info