]>
Commit | Line | Data |
---|---|---|
8d1fbe0c | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..compat import ( | |
6 | compat_parse_qs, | |
271808b6 | 7 | compat_str, |
8d1fbe0c | 8 | ) |
9 | from ..utils import ( | |
10 | int_or_none, | |
11 | try_get, | |
271808b6 | 12 | unified_timestamp, |
8d1fbe0c | 13 | ) |
14 | ||
15 | ||
16 | class PornFlipIE(InfoExtractor): | |
2e2a8e97 | 17 | _VALID_URL = r'https?://(?:www\.)?pornflip\.com/(?:v|embed)/(?P<id>[0-9A-Za-z-]{11})' |
271808b6 | 18 | _TESTS = [{ |
8d1fbe0c | 19 | 'url': 'https://www.pornflip.com/v/wz7DfNhMmep', |
20 | 'md5': '98c46639849145ae1fd77af532a9278c', | |
21 | 'info_dict': { | |
22 | 'id': 'wz7DfNhMmep', | |
23 | 'ext': 'mp4', | |
24 | 'title': '2 Amateurs swallow make his dream cumshots true', | |
8d1fbe0c | 25 | 'thumbnail': r're:^https?://.*\.jpg$', |
271808b6 S |
26 | 'duration': 112, |
27 | 'timestamp': 1481655502, | |
28 | 'upload_date': '20161213', | |
29 | 'uploader_id': '106786', | |
30 | 'uploader': 'figifoto', | |
31 | 'view_count': int, | |
8d1fbe0c | 32 | 'age_limit': 18, |
33 | } | |
271808b6 S |
34 | }, { |
35 | 'url': 'https://www.pornflip.com/embed/wz7DfNhMmep', | |
36 | 'only_matching': True, | |
2e2a8e97 JK |
37 | }, { |
38 | 'url': 'https://www.pornflip.com/v/EkRD6-vS2-s', | |
39 | 'only_matching': True, | |
40 | }, { | |
41 | 'url': 'https://www.pornflip.com/embed/EkRD6-vS2-s', | |
42 | 'only_matching': True, | |
271808b6 | 43 | }] |
8d1fbe0c | 44 | |
45 | def _real_extract(self, url): | |
46 | video_id = self._match_id(url) | |
271808b6 S |
47 | |
48 | webpage = self._download_webpage( | |
49 | 'https://www.pornflip.com/v/%s' % video_id, video_id) | |
50 | ||
51 | flashvars = compat_parse_qs(self._search_regex( | |
52 | r'<embed[^>]+flashvars=(["\'])(?P<flashvars>(?:(?!\1).)+)\1', | |
53 | webpage, 'flashvars', group='flashvars')) | |
54 | ||
8d1fbe0c | 55 | title = flashvars['video_vars[title]'][0] |
8d1fbe0c | 56 | |
271808b6 S |
57 | def flashvar(kind): |
58 | return try_get( | |
59 | flashvars, lambda x: x['video_vars[%s]' % kind][0], compat_str) | |
60 | ||
61 | formats = [] | |
62 | for key, value in flashvars.items(): | |
63 | if not (value and isinstance(value, list)): | |
64 | continue | |
65 | format_url = value[0] | |
66 | if key == 'video_vars[hds_manifest]': | |
67 | formats.extend(self._extract_mpd_formats( | |
68 | format_url, video_id, mpd_id='dash', fatal=False)) | |
69 | continue | |
70 | height = self._search_regex( | |
71 | r'video_vars\[video_urls\]\[(\d+)', key, 'height', default=None) | |
72 | if not height: | |
73 | continue | |
74 | formats.append({ | |
75 | 'url': format_url, | |
76 | 'format_id': 'http-%s' % height, | |
77 | 'height': int_or_none(height), | |
78 | }) | |
8d1fbe0c | 79 | self._sort_formats(formats) |
80 | ||
271808b6 S |
81 | uploader = self._html_search_regex( |
82 | (r'<span[^>]+class="name"[^>]*>\s*<a[^>]+>\s*<strong>(?P<uploader>[^<]+)', | |
83 | r'<meta[^>]+content=(["\'])[^>]*\buploaded by (?P<uploader>.+?)\1'), | |
84 | webpage, 'uploader', fatal=False, group='uploader') | |
85 | ||
8d1fbe0c | 86 | return { |
87 | 'id': video_id, | |
88 | 'formats': formats, | |
89 | 'title': title, | |
271808b6 S |
90 | 'thumbnail': flashvar('big_thumb'), |
91 | 'duration': int_or_none(flashvar('duration')), | |
92 | 'timestamp': unified_timestamp(self._html_search_meta( | |
93 | 'uploadDate', webpage, 'timestamp')), | |
94 | 'uploader_id': flashvar('author_id'), | |
8d1fbe0c | 95 | 'uploader': uploader, |
271808b6 | 96 | 'view_count': int_or_none(flashvar('views')), |
8d1fbe0c | 97 | 'age_limit': 18, |
98 | } |