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.

63 lines
2.0 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': 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. self._sort_formats(formats)
  33. title = self._html_search_regex(
  34. r'<title>([^<]+)\s*-\s*Sexu\.Com</title>', webpage, 'title')
  35. description = self._html_search_meta(
  36. 'description', webpage, 'description')
  37. thumbnail = jwvideo.get('image')
  38. categories_str = self._html_search_meta(
  39. 'keywords', webpage, 'categories')
  40. categories = (
  41. None if categories_str is None
  42. else categories_str.split(','))
  43. return {
  44. 'id': video_id,
  45. 'title': title,
  46. 'description': description,
  47. 'thumbnail': thumbnail,
  48. 'categories': categories,
  49. 'formats': formats,
  50. 'age_limit': 18,
  51. }