]>
Commit | Line | Data |
---|---|---|
191b7cbb PH |
1 | from __future__ import unicode_literals |
2 | ||
77ae6587 | 3 | import os |
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
1cc79574 | 7 | from ..compat import ( |
77ae6587 | 8 | compat_urllib_parse_urlparse, |
9 | compat_urllib_request, | |
10 | compat_urllib_parse, | |
11 | ) | |
12 | ||
191b7cbb | 13 | |
77ae6587 | 14 | class MofosexIE(InfoExtractor): |
1cc79574 | 15 | _VALID_URL = r'https?://(?:www\.)?(?P<url>mofosex\.com/videos/(?P<id>[0-9]+)/.*?\.html)' |
77ae6587 | 16 | _TEST = { |
191b7cbb PH |
17 | 'url': 'http://www.mofosex.com/videos/5018/japanese-teen-music-video.html', |
18 | 'md5': '1b2eb47ac33cc75d4a80e3026b613c5a', | |
19 | 'info_dict': { | |
20 | 'id': '5018', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Japanese Teen Music Video', | |
23 | 'age_limit': 18, | |
77ae6587 | 24 | } |
25 | } | |
26 | ||
27 | def _real_extract(self, url): | |
28 | mobj = re.match(self._VALID_URL, url) | |
1cc79574 | 29 | video_id = mobj.group('id') |
77ae6587 | 30 | url = 'http://www.' + mobj.group('url') |
31 | ||
32 | req = compat_urllib_request.Request(url) | |
33 | req.add_header('Cookie', 'age_verified=1') | |
34 | webpage = self._download_webpage(req, video_id) | |
35 | ||
191b7cbb PH |
36 | video_title = self._html_search_regex(r'<h1>(.+?)<', webpage, 'title') |
37 | video_url = compat_urllib_parse.unquote(self._html_search_regex(r'flashvars.video_url = \'([^\']+)', webpage, 'video_url')) | |
a56f9de1 JMF |
38 | path = compat_urllib_parse_urlparse(video_url).path |
39 | extension = os.path.splitext(path)[1][1:] | |
77ae6587 | 40 | format = path.split('/')[5].split('_')[:2] |
a56f9de1 | 41 | format = "-".join(format) |
77ae6587 | 42 | |
43 | age_limit = self._rta_search(webpage) | |
44 | ||
45 | return { | |
46 | 'id': video_id, | |
47 | 'title': video_title, | |
48 | 'url': video_url, | |
49 | 'ext': extension, | |
50 | 'format': format, | |
51 | 'format_id': format, | |
52 | 'age_limit': age_limit, | |
53 | } |