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