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.

62 lines
1.9 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. class SexuIE(InfoExtractor):
  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': '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': self._search_regex(
  29. r'^(\d+)[pP]', source.get('label', ''), 'height', default=None),
  30. } for source in sources if source.get('file')]
  31. self._sort_formats(formats)
  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. }