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.

61 lines
1.9 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class SexuIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?sexu\.com/(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://sexu.com/961791/',
  8. 'md5': 'ff615aca9691053c94f8f10d96cd7884',
  9. 'info_dict': {
  10. 'id': '961791',
  11. 'ext': 'mp4',
  12. 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b',
  13. 'description': 'md5:c5ed8625eb386855d5a7967bd7b77a54',
  14. 'categories': list, # NSFW
  15. 'thumbnail': 're:https?://.*\.jpg$',
  16. 'age_limit': 18,
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. webpage = self._download_webpage(url, video_id)
  23. quality_arr = self._search_regex(r'sources:\s*\[([^\]]+)\]', webpage, 'quality formats')
  24. formats = [{
  25. 'url': fmt[0].replace('\\', ''),
  26. 'format_id': fmt[1],
  27. 'height': int(fmt[1][:3]),
  28. } for fmt in re.findall(r'"file":"([^"]+)","label":"([^"]+)"', quality_arr)]
  29. self._sort_formats(formats)
  30. title = self._html_search_regex(
  31. r'<title>([^<]+)\s*-\s*Sexu.Com</title>', webpage, 'title')
  32. description = self._html_search_meta('description', webpage, 'description')
  33. thumbnail = self._html_search_regex(
  34. r'image:\s*"([^"]+)"',
  35. webpage, 'thumbnail', fatal=False)
  36. categories_str = self._html_search_meta('keywords', webpage, 'categories', fatal=False)
  37. categories = (
  38. None if categories_str is None
  39. else categories_str.split(','))
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'description': description,
  44. 'thumbnail': thumbnail,
  45. 'categories': categories,
  46. 'formats': formats,
  47. 'age_limit': 18,
  48. }