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