You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

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