2 from __future__ import unicode_literals
8 from ..compat import compat_urllib_parse
9 from .common import InfoExtractor
11 class PornoVoisinesIE(InfoExtractor):
12 _VALID_URL = r'^((?:http://)?(?:www\.)?pornovoisines.com)/showvideo/(\d+)/([^/]+)'
14 VIDEO_URL_TEMPLATE = 'http://stream%d.pornovoisines.com' \
15 '/static/media/video/transcoded/%s-640x360-1000-trscded.mp4'
17 SERVER_NUMBERS = (1, 2)
20 'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/',
21 'md5': '5ac670803bc12e9e7f9f662ce64cf1d1',
24 'display_id': 'recherche-appartement',
26 'title': "Recherche appartement",
27 'upload_date': '20140925',
30 'categories': ["Débutante", "Scénario", "Sodomie"],
31 'description': 're:^Pour la .+ original...$',
32 'thumbnail': 're:^http://',
34 'average_rating': float,
41 def build_video_url(cls, id):
42 server_nr = random.choice(cls.SERVER_NUMBERS)
43 return cls.VIDEO_URL_TEMPLATE % (server_nr, id)
46 def parse_upload_date(str):
47 return datetime.datetime.strptime(str, "%d-%m-%Y").strftime("%Y%m%d")
50 def parse_categories(str):
51 return map(lambda s: s.strip(), str.split(','))
53 def _real_extract(self, url):
54 mobj = re.match(self._VALID_URL, url)
55 url_prefix = mobj.group(1)
57 display_id = mobj.group(3)
59 webpage = self._download_webpage(url, id)
61 title = self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title',
63 url = self.build_video_url(id)
64 upload_date = self.parse_upload_date(
65 self._search_regex(r'Publié le (\d\d-\d\d-\d{4})', webpage,
67 view_count = int(self._search_regex(r'(\d+) vues', webpage, 'view count'))
68 duration = int(self._search_regex('Durée (\d+)', webpage, 'duration'))
69 categories = self.parse_categories(self._html_search_regex(
70 r'<li class="categorie">(.+?)</li>', webpage, "categories",
72 description = self._html_search_regex(
73 r'<article id="descriptif">(.+?)</article>', webpage, "description",
75 thumbnail = url_prefix + self._html_search_regex(re.compile(
76 '<div id="mediaspace' + id + '">.*?<img src="(.+?)"', re.DOTALL),
78 uploader = re.sub(r' *\| *$', '',
79 self._html_search_regex(r'<li class="auteur">(.+?)</li>', webpage,
80 "uploader", flags=re.DOTALL))
81 average_rating = float(self._search_regex(r'Note : (\d+,\d+)',
82 webpage, "average rating").replace(',', '.'))
83 comment_count = int(self._search_regex(r'\((\d+)\)', webpage,
88 'display_id': display_id,
91 'upload_date': upload_date,
92 'view_count': view_count,
94 'categories': categories,
95 'description': description,
96 'thumbnail': thumbnail,
98 'average_rating': average_rating,
99 'comment_count': comment_count,