]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/pornflip.py
[adobepass] Add MSO Sling TV (#596)
[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': {
32 'format': 'bestvideo',
33 'skip_download': True,
34 },
35 },
36 {
37 'url': 'https://www.pornflip.com/v/IrJEC40i21L',
38 'only_matching': True,
39 },
40 {
41 'url': 'https://www.pornflip.com/Z3jzbChC5-P/sexintaxi-e-sereyna-gomez-czech-naked-couple',
42 'only_matching': True,
43 },
44 {
45 'url': 'https://www.pornflip.com/embed/bLcDFxnrZnU',
46 'only_matching': True,
47 },
48 ]
49 _HOST = 'www.pornflip.com'
50
51 def _real_extract(self, url):
52 video_id = self._match_id(url)
53 webpage = self._download_webpage(
54 'https://{}/sv/{}'.format(self._HOST, video_id), video_id, headers={'host': self._HOST})
55 description = self._html_search_regex(r'&p\[summary\]=(.*?)\s*&p', webpage, 'description', fatal=False)
56 duration = self._search_regex(r'"duration":\s+"([^"]+)",', webpage, 'duration', fatal=False)
57 view_count = self._search_regex(r'"interactionCount":\s+"([^"]+)"', webpage, 'view_count', fatal=False)
58 title = self._html_search_regex(r'id="mediaPlayerTitleLink"[^>]*>(.+)</a>', webpage, 'title', fatal=False)
59 uploader = self._html_search_regex(r'class="title-chanel"[^>]*>[^<]*<a[^>]*>([^<]+)<', webpage, 'uploader', fatal=False)
60 upload_date = self._search_regex(r'"uploadDate":\s+"([^"]+)",', webpage, 'upload_date', fatal=False)
61 likes = self._html_search_regex(
62 r'class="btn btn-up-rating[^>]*>[^<]*<i[^>]*>[^<]*</i>[^>]*<span[^>]*>[^0-9]*([0-9]+)[^<0-9]*<', webpage, 'like_count', fatal=False)
63 dislikes = self._html_search_regex(
64 r'class="btn btn-down-rating[^>]*>[^<]*<i[^>]*>[^<]*</i>[^>]*<span[^>]*>[^0-9]*([0-9]+)[^<0-9]*<', webpage, 'dislike_count', fatal=False)
65 mpd_url = self._search_regex(r'"([^"]+userscontent.net/dash/[0-9]+/manifest.mpd[^"]*)"', webpage, 'mpd_url').replace('&amp;', '&')
66 formats = self._extract_mpd_formats(mpd_url, video_id, mpd_id='dash')
67 self._sort_formats(formats)
68
69 return {
70 'age_limit': 18,
71 'description': description,
72 'dislike_count': int_or_none(dislikes),
73 'duration': parse_duration(duration),
74 'formats': formats,
75 'id': video_id,
76 'like_count': int_or_none(likes),
77 'timestamp': parse_iso8601(upload_date),
78 'thumbnail': self._og_search_thumbnail(webpage),
79 'title': title,
80 'uploader': uploader,
81 'view_count': int_or_none(view_count),
82 }