]>
Commit | Line | Data |
---|---|---|
575dad3c RLN |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
575dad3c RLN |
5 | import random |
6 | ||
575dad3c | 7 | from .common import InfoExtractor |
7c39a655 S |
8 | from ..utils import ( |
9 | int_or_none, | |
10 | float_or_none, | |
11 | unified_strdate, | |
12 | ) | |
13 | ||
575dad3c RLN |
14 | |
15 | class PornoVoisinesIE(InfoExtractor): | |
7c39a655 | 16 | _VALID_URL = r'http://(?:www\.)?pornovoisines\.com/showvideo/(?P<id>\d+)/(?P<display_id>[^/]+)' |
575dad3c | 17 | |
7c39a655 | 18 | _VIDEO_URL_TEMPLATE = 'http://stream%d.pornovoisines.com' \ |
575dad3c RLN |
19 | '/static/media/video/transcoded/%s-640x360-1000-trscded.mp4' |
20 | ||
7c39a655 | 21 | _SERVER_NUMBERS = (1, 2) |
575dad3c RLN |
22 | |
23 | _TEST = { | |
24 | 'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/', | |
25 | 'md5': '5ac670803bc12e9e7f9f662ce64cf1d1', | |
26 | 'info_dict': { | |
27 | 'id': '1285', | |
28 | 'display_id': 'recherche-appartement', | |
29 | 'ext': 'mp4', | |
7c39a655 S |
30 | 'title': 'Recherche appartement', |
31 | 'description': 'md5:819ea0b785e2a04667a1a01cdc89594e', | |
32 | 'thumbnail': 're:^https?://.*\.jpg$', | |
575dad3c | 33 | 'upload_date': '20140925', |
575dad3c | 34 | 'duration': 120, |
7c39a655 | 35 | 'view_count': int, |
575dad3c | 36 | 'average_rating': float, |
54eb81a0 | 37 | 'categories': ['Débutantes', 'Scénario', 'Sodomie'], |
575dad3c RLN |
38 | 'age_limit': 18, |
39 | } | |
40 | } | |
41 | ||
42 | @classmethod | |
7c39a655 S |
43 | def build_video_url(cls, num): |
44 | return cls._VIDEO_URL_TEMPLATE % (random.choice(cls._SERVER_NUMBERS), num) | |
575dad3c RLN |
45 | |
46 | def _real_extract(self, url): | |
47 | mobj = re.match(self._VALID_URL, url) | |
7c39a655 S |
48 | video_id = mobj.group('id') |
49 | display_id = mobj.group('display_id') | |
50 | ||
51 | webpage = self._download_webpage(url, video_id) | |
52 | ||
53 | video_url = self.build_video_url(video_id) | |
54 | ||
55 | title = self._html_search_regex( | |
56 | r'<h1>(.+?)</h1>', webpage, 'title', flags=re.DOTALL) | |
575dad3c | 57 | description = self._html_search_regex( |
7c39a655 S |
58 | r'<article id="descriptif">(.+?)</article>', |
59 | webpage, "description", fatal=False, flags=re.DOTALL) | |
60 | ||
61 | thumbnail = self._search_regex( | |
62 | r'<div id="mediaspace%s">\s*<img src="/?([^"]+)"' % video_id, | |
63 | webpage, 'thumbnail', fatal=False) | |
64 | if thumbnail: | |
65 | thumbnail = 'http://www.pornovoisines.com/%s' % thumbnail | |
66 | ||
67 | upload_date = unified_strdate(self._search_regex( | |
68 | r'Publié le ([\d-]+)', webpage, 'upload date', fatal=False)) | |
69 | duration = int_or_none(self._search_regex( | |
70 | 'Durée (\d+)', webpage, 'duration', fatal=False)) | |
71 | view_count = int_or_none(self._search_regex( | |
72 | r'(\d+) vues', webpage, 'view count', fatal=False)) | |
73 | average_rating = self._search_regex( | |
54eb81a0 | 74 | r'Note\s*:\s*(\d+(?:,\d+)?)', webpage, 'average rating', fatal=False) |
7c39a655 S |
75 | if average_rating: |
76 | average_rating = float_or_none(average_rating.replace(',', '.')) | |
77 | ||
78 | categories = self._html_search_meta( | |
79 | 'keywords', webpage, 'categories', fatal=False) | |
80 | if categories: | |
81 | categories = [category.strip() for category in categories.split(',')] | |
575dad3c RLN |
82 | |
83 | return { | |
7c39a655 | 84 | 'id': video_id, |
575dad3c | 85 | 'display_id': display_id, |
7c39a655 | 86 | 'url': video_url, |
575dad3c | 87 | 'title': title, |
575dad3c RLN |
88 | 'description': description, |
89 | 'thumbnail': thumbnail, | |
7c39a655 S |
90 | 'upload_date': upload_date, |
91 | 'duration': duration, | |
92 | 'view_count': view_count, | |
575dad3c | 93 | 'average_rating': average_rating, |
7c39a655 | 94 | 'categories': categories, |
575dad3c RLN |
95 | 'age_limit': 18, |
96 | } |