2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class PornoVoisinesIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/videos/show/(?P<id>\d+)/(?P<display_id>[^/.]+)'
18 'url': 'http://www.pornovoisines.com/videos/show/919/recherche-appartement.html',
19 'md5': '6f8aca6a058592ab49fe701c8ba8317b',
22 'display_id': 'recherche-appartement',
24 'title': 'Recherche appartement',
25 'description': 'md5:fe10cb92ae2dd3ed94bb4080d11ff493',
26 'thumbnail': r're:^https?://.*\.jpg$',
27 'upload_date': '20140925',
30 'average_rating': float,
31 'categories': ['Débutante', 'Débutantes', 'Scénario', 'Sodomie'],
41 def _real_extract(self, url):
42 mobj = re.match(self._VALID_URL, url)
43 video_id = mobj.group('id')
44 display_id = mobj.group('display_id')
46 settings_url = self._download_json(
47 'http://www.pornovoisines.com/api/video/%s/getsettingsurl/' % video_id,
48 video_id, note='Getting settings URL')['video_settings_url']
49 settings = self._download_json(settings_url, video_id)['data']
52 for kind, data in settings['variants'].items():
54 formats.extend(self._extract_m3u8_formats(
55 data, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
60 'height': item.get('height'),
61 'bitrate': item.get('bitrate'),
63 self._sort_formats(formats)
65 webpage = self._download_webpage(url, video_id)
67 title = self._og_search_title(webpage)
68 description = self._og_search_description(webpage)
70 # The webpage has a bug - there's no space between "thumb" and src=
71 thumbnail = self._html_search_regex(
72 r'<img[^>]+class=([\'"])thumb\1[^>]*src=([\'"])(?P<url>[^"]+)\2',
73 webpage, 'thumbnail', fatal=False, group='url')
75 upload_date = unified_strdate(self._search_regex(
76 r'Le\s*<b>([\d/]+)', webpage, 'upload date', fatal=False))
77 duration = settings.get('main', {}).get('duration')
78 view_count = int_or_none(self._search_regex(
79 r'(\d+) vues', webpage, 'view count', fatal=False))
80 average_rating = self._search_regex(
81 r'Note\s*:\s*(\d+(?:,\d+)?)', webpage, 'average rating', fatal=False)
83 average_rating = float_or_none(average_rating.replace(',', '.'))
85 categories = self._html_search_regex(
86 r'(?s)Catégories\s*:\s*<b>(.+?)</b>', webpage, 'categories', fatal=False)
88 categories = [category.strip() for category in categories.split(',')]
92 } for subtitle in settings.get('main', {}).get('vtt_tracks', {}).values()]}
96 'display_id': display_id,
99 'description': description,
100 'thumbnail': thumbnail,
101 'upload_date': upload_date,
102 'duration': duration,
103 'view_count': view_count,
104 'average_rating': average_rating,
105 'categories': categories,
107 'subtitles': subtitles,