yourporn.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from .common import InfoExtractor
  2. from ..compat import compat_str
  3. from ..utils import (
  4. parse_duration,
  5. urljoin,
  6. )
  7. class YourPornIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?sxyprn\.com/post/(?P<id>[^/?#&.]+)'
  9. _TESTS = [{
  10. 'url': 'https://sxyprn.com/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. parts = 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].split('/')
  35. num = 0
  36. for c in parts[6] + parts[7]:
  37. if c.isnumeric():
  38. num += int(c)
  39. parts[5] = compat_str(int(parts[5]) - num)
  40. parts[1] += '8'
  41. video_url = urljoin(url, '/'.join(parts))
  42. title = (self._search_regex(
  43. r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title',
  44. default=None) or self._og_search_description(webpage)).strip()
  45. thumbnail = self._og_search_thumbnail(webpage)
  46. duration = parse_duration(self._search_regex(
  47. r'duration\s*:\s*<[^>]+>([\d:]+)', webpage, 'duration',
  48. default=None))
  49. return {
  50. 'id': video_id,
  51. 'url': video_url,
  52. 'title': title,
  53. 'thumbnail': thumbnail,
  54. 'duration': duration,
  55. 'age_limit': 18,
  56. 'ext': 'mp4',
  57. }