pornflip.py 3.4 KB

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