aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/pornovoisines.py80
1 files changed, 46 insertions, 34 deletions
diff --git a/youtube_dl/extractor/pornovoisines.py b/youtube_dl/extractor/pornovoisines.py
index 6b51e5c54..58f557e39 100644
--- a/youtube_dl/extractor/pornovoisines.py
+++ b/youtube_dl/extractor/pornovoisines.py
@@ -2,7 +2,6 @@
from __future__ import unicode_literals
import re
-import random
from .common import InfoExtractor
from ..utils import (
@@ -13,61 +12,69 @@ from ..utils import (
class PornoVoisinesIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/showvideo/(?P<id>\d+)/(?P<display_id>[^/]+)'
-
- _VIDEO_URL_TEMPLATE = 'http://stream%d.pornovoisines.com' \
- '/static/media/video/transcoded/%s-640x360-1000-trscded.mp4'
-
- _SERVER_NUMBERS = (1, 2)
+ _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/videos/show/(?P<id>\d+)/(?P<display_id>[^/.]+)'
_TEST = {
- 'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/',
- 'md5': '5ac670803bc12e9e7f9f662ce64cf1d1',
+ 'url': 'http://www.pornovoisines.com/videos/show/919/recherche-appartement.html',
+ 'md5': '6f8aca6a058592ab49fe701c8ba8317b',
'info_dict': {
- 'id': '1285',
+ 'id': '919',
'display_id': 'recherche-appartement',
'ext': 'mp4',
'title': 'Recherche appartement',
- 'description': 'md5:819ea0b785e2a04667a1a01cdc89594e',
+ 'description': 'md5:fe10cb92ae2dd3ed94bb4080d11ff493',
'thumbnail': 're:^https?://.*\.jpg$',
'upload_date': '20140925',
'duration': 120,
'view_count': int,
'average_rating': float,
- 'categories': ['Débutantes', 'Scénario', 'Sodomie'],
+ 'categories': ['Débutante', 'Débutantes', 'Scénario', 'Sodomie'],
'age_limit': 18,
+ 'subtitles': {
+ 'fr': [{
+ 'ext': 'vtt',
+ }]
+ },
}
}
- @classmethod
- def build_video_url(cls, num):
- return cls._VIDEO_URL_TEMPLATE % (random.choice(cls._SERVER_NUMBERS), num)
-
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
display_id = mobj.group('display_id')
- webpage = self._download_webpage(url, video_id)
+ settings_url = self._download_json(
+ 'http://www.pornovoisines.com/api/video/%s/getsettingsurl/' % video_id,
+ video_id, note='Getting settings URL')['video_settings_url']
+ settings = self._download_json(settings_url, video_id)['data']
+
+ formats = []
+ for kind, data in settings['variants'].items():
+ if kind == 'HLS':
+ formats.extend(self._extract_m3u8_formats(
+ data, video_id, ext='mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
+ elif kind == 'MP4':
+ for item in data:
+ formats.append({
+ 'url': item['url'],
+ 'height': item.get('height'),
+ 'bitrate': item.get('bitrate'),
+ })
+ self._sort_formats(formats)
- video_url = self.build_video_url(video_id)
+ webpage = self._download_webpage(url, video_id)
- title = self._html_search_regex(
- r'<h1>(.+?)</h1>', webpage, 'title', flags=re.DOTALL)
- description = self._html_search_regex(
- r'<article id="descriptif">(.+?)</article>',
- webpage, 'description', fatal=False, flags=re.DOTALL)
+ title = self._og_search_title(webpage)
+ description = self._og_search_description(webpage)
- thumbnail = self._search_regex(
- r'<div id="mediaspace%s">\s*<img src="/?([^"]+)"' % video_id,
- webpage, 'thumbnail', fatal=False)
- if thumbnail:
- thumbnail = 'http://www.pornovoisines.com/%s' % thumbnail
+ # The webpage has a bug - there's no space between "thumb" and src=
+ thumbnail = self._html_search_regex(
+ r'<img[^>]+class=([\'"])thumb\1[^>]*src=([\'"])(?P<url>[^"]+)\2',
+ webpage, 'thumbnail', fatal=False, group='url')
upload_date = unified_strdate(self._search_regex(
- r'Publié le ([\d-]+)', webpage, 'upload date', fatal=False))
- duration = int_or_none(self._search_regex(
- 'Durée (\d+)', webpage, 'duration', fatal=False))
+ r'Le\s*<b>([\d/]+)', webpage, 'upload date', fatal=False))
+ duration = settings.get('main', {}).get('duration')
view_count = int_or_none(self._search_regex(
r'(\d+) vues', webpage, 'view count', fatal=False))
average_rating = self._search_regex(
@@ -75,15 +82,19 @@ class PornoVoisinesIE(InfoExtractor):
if average_rating:
average_rating = float_or_none(average_rating.replace(',', '.'))
- categories = self._html_search_meta(
- 'keywords', webpage, 'categories', fatal=False)
+ categories = self._html_search_regex(
+ r'(?s)Catégories\s*:\s*<b>(.+?)</b>', webpage, 'categories', fatal=False)
if categories:
categories = [category.strip() for category in categories.split(',')]
+ subtitles = {'fr': [{
+ 'url': subtitle,
+ } for subtitle in settings.get('main', {}).get('vtt_tracks', {}).values()]}
+
return {
'id': video_id,
'display_id': display_id,
- 'url': video_url,
+ 'formats': formats,
'title': title,
'description': description,
'thumbnail': thumbnail,
@@ -93,4 +104,5 @@ class PornoVoisinesIE(InfoExtractor):
'average_rating': average_rating,
'categories': categories,
'age_limit': 18,
+ 'subtitles': subtitles,
}