pornflip.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from .common import InfoExtractor
  2. from ..utils import int_or_none, parse_duration, parse_iso8601
  3. class PornFlipIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?pornflip\.com/(?:(embed|sv|v)/)?(?P<id>[^/]+)'
  5. _TESTS = [
  6. {
  7. 'url': 'https://www.pornflip.com/dzv9Mtw1qj2/sv/brazzers-double-dare-two-couples-fucked-jenna-reid-maya-bijou',
  8. 'info_dict': {
  9. 'id': 'dzv9Mtw1qj2',
  10. 'ext': 'mp4',
  11. 'title': 'Brazzers - Double Dare Two couples fucked Jenna Reid Maya Bijou',
  12. 'description': 'md5:d2b69e6cc743c5fd158e162aa7f05821',
  13. 'duration': 476,
  14. 'like_count': int,
  15. 'dislike_count': int,
  16. 'view_count': int,
  17. 'timestamp': 1617846819,
  18. 'upload_date': '20210408',
  19. 'uploader': 'Brazzers',
  20. 'age_limit': 18,
  21. },
  22. 'params': {
  23. 'skip_download': True,
  24. },
  25. },
  26. {
  27. 'url': 'https://www.pornflip.com/v/IrJEC40i21L',
  28. 'only_matching': True,
  29. },
  30. {
  31. 'url': 'https://www.pornflip.com/Z3jzbChC5-P/sexintaxi-e-sereyna-gomez-czech-naked-couple',
  32. 'only_matching': True,
  33. },
  34. {
  35. 'url': 'https://www.pornflip.com/embed/bLcDFxnrZnU',
  36. 'only_matching': True,
  37. },
  38. ]
  39. _HOST = 'www.pornflip.com'
  40. def _real_extract(self, url):
  41. video_id = self._match_id(url)
  42. webpage = self._download_webpage(
  43. f'https://{self._HOST}/sv/{video_id}', video_id, headers={'host': self._HOST})
  44. description = self._html_search_regex(r'&p\[summary\]=(.*?)\s*&p', webpage, 'description', fatal=False)
  45. duration = self._search_regex(r'"duration":\s+"([^"]+)",', webpage, 'duration', fatal=False)
  46. view_count = self._search_regex(r'"interactionCount":\s+"([^"]+)"', webpage, 'view_count', fatal=False)
  47. title = self._html_search_regex(r'id="mediaPlayerTitleLink"[^>]*>(.+)</a>', webpage, 'title', fatal=False)
  48. uploader = self._html_search_regex(r'class="title-chanel"[^>]*>[^<]*<a[^>]*>([^<]+)<', webpage, 'uploader', fatal=False)
  49. upload_date = self._search_regex(r'"uploadDate":\s+"([^"]+)",', webpage, 'upload_date', fatal=False)
  50. likes = self._html_search_regex(
  51. r'class="btn btn-up-rating[^>]*>[^<]*<i[^>]*>[^<]*</i>[^>]*<span[^>]*>[^0-9]*([0-9]+)[^<0-9]*<', webpage, 'like_count', fatal=False)
  52. dislikes = self._html_search_regex(
  53. r'class="btn btn-down-rating[^>]*>[^<]*<i[^>]*>[^<]*</i>[^>]*<span[^>]*>[^0-9]*([0-9]+)[^<0-9]*<', webpage, 'dislike_count', fatal=False)
  54. mpd_url = self._search_regex(r'"([^"]+userscontent.net/dash/[0-9]+/manifest.mpd[^"]*)"', webpage, 'mpd_url').replace('&amp;', '&')
  55. formats = self._extract_mpd_formats(mpd_url, video_id, mpd_id='dash')
  56. return {
  57. 'age_limit': 18,
  58. 'description': description,
  59. 'dislike_count': int_or_none(dislikes),
  60. 'duration': parse_duration(duration),
  61. 'formats': formats,
  62. 'id': video_id,
  63. 'like_count': int_or_none(likes),
  64. 'timestamp': parse_iso8601(upload_date),
  65. 'thumbnail': self._og_search_thumbnail(webpage),
  66. 'title': title,
  67. 'uploader': uploader,
  68. 'view_count': int_or_none(view_count),
  69. }