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