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.

57 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_duration,
  5. urljoin,
  6. )
  7. class YourPornIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?(?:yourporn\.sexy|sxyprn\.com)/post/(?P<id>[^/?#&.]+)'
  9. _TESTS = [{
  10. 'url': 'https://yourporn.sexy/post/57ffcb2e1179b.html',
  11. 'md5': '6f8682b6464033d87acaa7a8ff0c092e',
  12. 'info_dict': {
  13. 'id': '57ffcb2e1179b',
  14. 'ext': 'mp4',
  15. 'title': 'md5:c9f43630bd968267672651ba905a7d35',
  16. 'thumbnail': r're:^https?://.*\.jpg$',
  17. 'duration': 165,
  18. 'age_limit': 18,
  19. },
  20. 'params': {
  21. 'skip_download': True,
  22. },
  23. }, {
  24. 'url': 'https://sxyprn.com/post/57ffcb2e1179b.html',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(url, video_id)
  30. video_url = urljoin(url, self._parse_json(
  31. self._search_regex(
  32. r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info',
  33. group='data'),
  34. video_id)[video_id]).replace('/cdn/', '/cdn4/')
  35. title = (self._search_regex(
  36. r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title',
  37. default=None) or self._og_search_description(webpage)).strip()
  38. thumbnail = self._og_search_thumbnail(webpage)
  39. duration = parse_duration(self._search_regex(
  40. r'duration\s*:\s*<[^>]+>([\d:]+)', webpage, 'duration',
  41. default=None))
  42. return {
  43. 'id': video_id,
  44. 'url': video_url,
  45. 'title': title,
  46. 'thumbnail': thumbnail,
  47. 'duration': duration,
  48. 'age_limit': 18,
  49. }