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. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. quality_arr = self._search_regex(
  23. r'sources:\s*\[([^\]]+)\]', webpage, 'forrmat string')
  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(
  33. 'description', webpage, 'description')
  34. thumbnail = self._html_search_regex(
  35. r'image:\s*"([^"]+)"',
  36. webpage, 'thumbnail', fatal=False)
  37. categories_str = self._html_search_meta(
  38. 'keywords', webpage, 'categories')
  39. categories = (
  40. None if categories_str is None
  41. else categories_str.split(','))
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'description': description,
  46. 'thumbnail': thumbnail,
  47. 'categories': categories,
  48. 'formats': formats,
  49. 'age_limit': 18,
  50. }