1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-20 20:12:52 +08:00

[pornovoisines] Fix extraction (closes #10469)

This commit is contained in:
Yen Chi Hsuan 2016-09-04 17:01:39 +08:00
parent 622638512b
commit b29cd56591
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30
2 changed files with 47 additions and 34 deletions

View File

@ -1,6 +1,7 @@
version <unreleased> version <unreleased>
Extractors Extractors
* [pornvoisines] Fix extraction (#10469)
* [rottentomatoes] Fix extraction (#10467) * [rottentomatoes] Fix extraction (#10467)
* [youjizz] Fix extraction (#10437) * [youjizz] Fix extraction (#10437)
+ [foxnews] Add support for FoxNews Insider (#10445) + [foxnews] Add support for FoxNews Insider (#10445)

View File

@ -2,7 +2,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
import random
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
@ -13,61 +12,69 @@ from ..utils import (
class PornoVoisinesIE(InfoExtractor): class PornoVoisinesIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/showvideo/(?P<id>\d+)/(?P<display_id>[^/]+)' _VALID_URL = r'https?://(?:www\.)?pornovoisines\.com/videos/show/(?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)
_TEST = { _TEST = {
'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/', 'url': 'http://www.pornovoisines.com/videos/show/919/recherche-appartement.html',
'md5': '5ac670803bc12e9e7f9f662ce64cf1d1', 'md5': '6f8aca6a058592ab49fe701c8ba8317b',
'info_dict': { 'info_dict': {
'id': '1285', 'id': '919',
'display_id': 'recherche-appartement', 'display_id': 'recherche-appartement',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Recherche appartement', 'title': 'Recherche appartement',
'description': 'md5:819ea0b785e2a04667a1a01cdc89594e', 'description': 'md5:fe10cb92ae2dd3ed94bb4080d11ff493',
'thumbnail': 're:^https?://.*\.jpg$', 'thumbnail': 're:^https?://.*\.jpg$',
'upload_date': '20140925', 'upload_date': '20140925',
'duration': 120, 'duration': 120,
'view_count': int, 'view_count': int,
'average_rating': float, 'average_rating': float,
'categories': ['Débutantes', 'Scénario', 'Sodomie'], 'categories': ['Débutante', 'Débutantes', 'Scénario', 'Sodomie'],
'age_limit': 18, '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): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id') video_id = mobj.group('id')
display_id = mobj.group('display_id') display_id = mobj.group('display_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)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_url = self.build_video_url(video_id) title = self._og_search_title(webpage)
description = self._og_search_description(webpage)
title = self._html_search_regex( # The webpage has a bug - there's no space between "thumb" and src=
r'<h1>(.+?)</h1>', webpage, 'title', flags=re.DOTALL) thumbnail = self._html_search_regex(
description = self._html_search_regex( r'<img[^>]+class=([\'"])thumb\1[^>]*src=([\'"])(?P<url>[^"]+)\2',
r'<article id="descriptif">(.+?)</article>', webpage, 'thumbnail', fatal=False, group='url')
webpage, 'description', fatal=False, flags=re.DOTALL)
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
upload_date = unified_strdate(self._search_regex( upload_date = unified_strdate(self._search_regex(
r'Publié le ([\d-]+)', webpage, 'upload date', fatal=False)) r'Le\s*<b>([\d/]+)', webpage, 'upload date', fatal=False))
duration = int_or_none(self._search_regex( duration = settings.get('main', {}).get('duration')
'Durée (\d+)', webpage, 'duration', fatal=False))
view_count = int_or_none(self._search_regex( view_count = int_or_none(self._search_regex(
r'(\d+) vues', webpage, 'view count', fatal=False)) r'(\d+) vues', webpage, 'view count', fatal=False))
average_rating = self._search_regex( average_rating = self._search_regex(
@ -75,15 +82,19 @@ class PornoVoisinesIE(InfoExtractor):
if average_rating: if average_rating:
average_rating = float_or_none(average_rating.replace(',', '.')) average_rating = float_or_none(average_rating.replace(',', '.'))
categories = self._html_search_meta( categories = self._html_search_regex(
'keywords', webpage, 'categories', fatal=False) r'(?s)Catégories\s*:\s*<b>(.+?)</b>', webpage, 'categories', fatal=False)
if categories: if categories:
categories = [category.strip() for category in categories.split(',')] categories = [category.strip() for category in categories.split(',')]
subtitles = {'fr': [{
'url': subtitle,
} for subtitle in settings.get('main', {}).get('vtt_tracks', {}).values()]}
return { return {
'id': video_id, 'id': video_id,
'display_id': display_id, 'display_id': display_id,
'url': video_url, 'formats': formats,
'title': title, 'title': title,
'description': description, 'description': description,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
@ -93,4 +104,5 @@ class PornoVoisinesIE(InfoExtractor):
'average_rating': average_rating, 'average_rating': average_rating,
'categories': categories, 'categories': categories,
'age_limit': 18, 'age_limit': 18,
'subtitles': subtitles,
} }