]>
Commit | Line | Data |
---|---|---|
575dad3c | 1 | from .common import InfoExtractor |
7c39a655 S |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | float_or_none, | |
5 | unified_strdate, | |
6 | ) | |
7 | ||
575dad3c RLN |
8 | |
9 | class PornoVoisinesIE(InfoExtractor): | |
b29cd565 | 10 | _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/videos/show/(?P<id>\d+)/(?P<display_id>[^/.]+)' |
575dad3c RLN |
11 | |
12 | _TEST = { | |
b29cd565 YCH |
13 | 'url': 'http://www.pornovoisines.com/videos/show/919/recherche-appartement.html', |
14 | 'md5': '6f8aca6a058592ab49fe701c8ba8317b', | |
575dad3c | 15 | 'info_dict': { |
b29cd565 | 16 | 'id': '919', |
575dad3c RLN |
17 | 'display_id': 'recherche-appartement', |
18 | 'ext': 'mp4', | |
7c39a655 | 19 | 'title': 'Recherche appartement', |
b29cd565 | 20 | 'description': 'md5:fe10cb92ae2dd3ed94bb4080d11ff493', |
ec85ded8 | 21 | 'thumbnail': r're:^https?://.*\.jpg$', |
575dad3c | 22 | 'upload_date': '20140925', |
575dad3c | 23 | 'duration': 120, |
7c39a655 | 24 | 'view_count': int, |
575dad3c | 25 | 'average_rating': float, |
b29cd565 | 26 | 'categories': ['Débutante', 'Débutantes', 'Scénario', 'Sodomie'], |
575dad3c | 27 | 'age_limit': 18, |
b29cd565 YCH |
28 | 'subtitles': { |
29 | 'fr': [{ | |
30 | 'ext': 'vtt', | |
31 | }] | |
32 | }, | |
575dad3c RLN |
33 | } |
34 | } | |
35 | ||
575dad3c | 36 | def _real_extract(self, url): |
5ad28e7f | 37 | mobj = self._match_valid_url(url) |
7c39a655 S |
38 | video_id = mobj.group('id') |
39 | display_id = mobj.group('display_id') | |
40 | ||
b29cd565 YCH |
41 | settings_url = self._download_json( |
42 | 'http://www.pornovoisines.com/api/video/%s/getsettingsurl/' % video_id, | |
43 | video_id, note='Getting settings URL')['video_settings_url'] | |
44 | settings = self._download_json(settings_url, video_id)['data'] | |
45 | ||
46 | formats = [] | |
47 | for kind, data in settings['variants'].items(): | |
48 | if kind == 'HLS': | |
49 | formats.extend(self._extract_m3u8_formats( | |
50 | data, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls')) | |
51 | elif kind == 'MP4': | |
52 | for item in data: | |
53 | formats.append({ | |
54 | 'url': item['url'], | |
55 | 'height': item.get('height'), | |
56 | 'bitrate': item.get('bitrate'), | |
57 | }) | |
7c39a655 | 58 | |
b29cd565 | 59 | webpage = self._download_webpage(url, video_id) |
7c39a655 | 60 | |
b29cd565 YCH |
61 | title = self._og_search_title(webpage) |
62 | description = self._og_search_description(webpage) | |
7c39a655 | 63 | |
b29cd565 YCH |
64 | # The webpage has a bug - there's no space between "thumb" and src= |
65 | thumbnail = self._html_search_regex( | |
66 | r'<img[^>]+class=([\'"])thumb\1[^>]*src=([\'"])(?P<url>[^"]+)\2', | |
67 | webpage, 'thumbnail', fatal=False, group='url') | |
7c39a655 S |
68 | |
69 | upload_date = unified_strdate(self._search_regex( | |
b29cd565 YCH |
70 | r'Le\s*<b>([\d/]+)', webpage, 'upload date', fatal=False)) |
71 | duration = settings.get('main', {}).get('duration') | |
7c39a655 S |
72 | view_count = int_or_none(self._search_regex( |
73 | r'(\d+) vues', webpage, 'view count', fatal=False)) | |
74 | average_rating = self._search_regex( | |
54eb81a0 | 75 | r'Note\s*:\s*(\d+(?:,\d+)?)', webpage, 'average rating', fatal=False) |
7c39a655 S |
76 | if average_rating: |
77 | average_rating = float_or_none(average_rating.replace(',', '.')) | |
78 | ||
b29cd565 YCH |
79 | categories = self._html_search_regex( |
80 | r'(?s)Catégories\s*:\s*<b>(.+?)</b>', webpage, 'categories', fatal=False) | |
7c39a655 S |
81 | if categories: |
82 | categories = [category.strip() for category in categories.split(',')] | |
575dad3c | 83 | |
b29cd565 YCH |
84 | subtitles = {'fr': [{ |
85 | 'url': subtitle, | |
86 | } for subtitle in settings.get('main', {}).get('vtt_tracks', {}).values()]} | |
87 | ||
575dad3c | 88 | return { |
7c39a655 | 89 | 'id': video_id, |
575dad3c | 90 | 'display_id': display_id, |
b29cd565 | 91 | 'formats': formats, |
575dad3c | 92 | 'title': title, |
575dad3c RLN |
93 | 'description': description, |
94 | 'thumbnail': thumbnail, | |
7c39a655 S |
95 | 'upload_date': upload_date, |
96 | 'duration': duration, | |
97 | 'view_count': view_count, | |
575dad3c | 98 | 'average_rating': average_rating, |
7c39a655 | 99 | 'categories': categories, |
575dad3c | 100 | 'age_limit': 18, |
b29cd565 | 101 | 'subtitles': subtitles, |
575dad3c | 102 | } |