sexu.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from .common import InfoExtractor
  2. class SexuIE(InfoExtractor):
  3. _WORKING = False
  4. _VALID_URL = r'https?://(?:www\.)?sexu\.com/(?P<id>\d+)'
  5. _TEST = {
  6. 'url': 'http://sexu.com/961791/',
  7. 'md5': 'ff615aca9691053c94f8f10d96cd7884',
  8. 'info_dict': {
  9. 'id': '961791',
  10. 'ext': 'mp4',
  11. 'title': 'md5:4d05a19a5fc049a63dbbaf05fb71d91b',
  12. 'description': 'md5:2b75327061310a3afb3fbd7d09e2e403',
  13. 'categories': list, # NSFW
  14. 'thumbnail': r're:https?://.*\.jpg$',
  15. 'age_limit': 18,
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. jwvideo = self._parse_json(
  22. self._search_regex(r'\.setup\(\s*({.+?})\s*\);', webpage, 'jwvideo'),
  23. video_id)
  24. sources = jwvideo['sources']
  25. formats = [{
  26. 'url': source['file'].replace('\\', ''),
  27. 'format_id': source.get('label'),
  28. 'height': int(self._search_regex(
  29. r'^(\d+)[pP]', source.get('label', ''), 'height',
  30. default=None)),
  31. } for source in sources if source.get('file')]
  32. title = self._html_search_regex(
  33. r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title')
  34. description = self._html_search_meta(
  35. 'description', webpage, 'description')
  36. thumbnail = jwvideo.get('image')
  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. }