mirror of
https://codeberg.org/polarisfm/youtube-dl.git
synced 2024-12-23 08:12:28 +00:00
[pornovoisines] Simplify
This commit is contained in:
parent
8cf70de428
commit
7c39a65543
1 changed files with 53 additions and 58 deletions
|
@ -2,19 +2,23 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import datetime
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from ..compat import compat_urllib_parse
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
|
float_or_none,
|
||||||
|
unified_strdate,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PornoVoisinesIE(InfoExtractor):
|
class PornoVoisinesIE(InfoExtractor):
|
||||||
_VALID_URL = r'^((?:http://)?(?:www\.)?pornovoisines.com)/showvideo/(\d+)/([^/]+)'
|
_VALID_URL = r'http://(?:www\.)?pornovoisines\.com/showvideo/(?P<id>\d+)/(?P<display_id>[^/]+)'
|
||||||
|
|
||||||
VIDEO_URL_TEMPLATE = 'http://stream%d.pornovoisines.com' \
|
_VIDEO_URL_TEMPLATE = 'http://stream%d.pornovoisines.com' \
|
||||||
'/static/media/video/transcoded/%s-640x360-1000-trscded.mp4'
|
'/static/media/video/transcoded/%s-640x360-1000-trscded.mp4'
|
||||||
|
|
||||||
SERVER_NUMBERS = (1, 2)
|
_SERVER_NUMBERS = (1, 2)
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/',
|
'url': 'http://www.pornovoisines.com/showvideo/1285/recherche-appartement/',
|
||||||
|
@ -23,79 +27,70 @@ class PornoVoisinesIE(InfoExtractor):
|
||||||
'id': '1285',
|
'id': '1285',
|
||||||
'display_id': 'recherche-appartement',
|
'display_id': 'recherche-appartement',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': "Recherche appartement",
|
'title': 'Recherche appartement',
|
||||||
|
'description': 'md5:819ea0b785e2a04667a1a01cdc89594e',
|
||||||
|
'thumbnail': 're:^https?://.*\.jpg$',
|
||||||
'upload_date': '20140925',
|
'upload_date': '20140925',
|
||||||
'view_count': int,
|
|
||||||
'duration': 120,
|
'duration': 120,
|
||||||
'categories': ["Débutante", "Scénario", "Sodomie"],
|
'view_count': int,
|
||||||
'description': 're:^Pour la .+ original...$',
|
|
||||||
'thumbnail': 're:^http://',
|
|
||||||
'uploader': "JMTV",
|
|
||||||
'average_rating': float,
|
'average_rating': float,
|
||||||
'comment_count': int,
|
'categories': ['Débutante', 'Scénario', 'Sodomie'],
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_video_url(cls, id):
|
def build_video_url(cls, num):
|
||||||
server_nr = random.choice(cls.SERVER_NUMBERS)
|
return cls._VIDEO_URL_TEMPLATE % (random.choice(cls._SERVER_NUMBERS), num)
|
||||||
return cls.VIDEO_URL_TEMPLATE % (server_nr, id)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def parse_upload_date(str):
|
|
||||||
return datetime.datetime.strptime(str, "%d-%m-%Y").strftime("%Y%m%d")
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def parse_categories(str):
|
|
||||||
return map(lambda s: s.strip(), str.split(','))
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
url_prefix = mobj.group(1)
|
video_id = mobj.group('id')
|
||||||
id = mobj.group(2)
|
display_id = mobj.group('display_id')
|
||||||
display_id = mobj.group(3)
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
title = self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title',
|
video_url = self.build_video_url(video_id)
|
||||||
flags=re.DOTALL)
|
|
||||||
url = self.build_video_url(id)
|
title = self._html_search_regex(
|
||||||
upload_date = self.parse_upload_date(
|
r'<h1>(.+?)</h1>', webpage, 'title', flags=re.DOTALL)
|
||||||
self._search_regex(r'Publié le (\d\d-\d\d-\d{4})', webpage,
|
|
||||||
'upload date'))
|
|
||||||
view_count = int(self._search_regex(r'(\d+) vues', webpage, 'view count'))
|
|
||||||
duration = int(self._search_regex('Durée (\d+)', webpage, 'duration'))
|
|
||||||
categories = self.parse_categories(self._html_search_regex(
|
|
||||||
r'<li class="categorie">(.+?)</li>', webpage, "categories",
|
|
||||||
flags=re.DOTALL))
|
|
||||||
description = self._html_search_regex(
|
description = self._html_search_regex(
|
||||||
r'<article id="descriptif">(.+?)</article>', webpage, "description",
|
r'<article id="descriptif">(.+?)</article>',
|
||||||
flags=re.DOTALL)
|
webpage, "description", fatal=False, flags=re.DOTALL)
|
||||||
thumbnail = url_prefix + self._html_search_regex(re.compile(
|
|
||||||
'<div id="mediaspace' + id + '">.*?<img src="(.+?)"', re.DOTALL),
|
thumbnail = self._search_regex(
|
||||||
webpage, "thumbnail")
|
r'<div id="mediaspace%s">\s*<img src="/?([^"]+)"' % video_id,
|
||||||
uploader = re.sub(r' *\| *$', '',
|
webpage, 'thumbnail', fatal=False)
|
||||||
self._html_search_regex(r'<li class="auteur">(.+?)</li>', webpage,
|
if thumbnail:
|
||||||
"uploader", flags=re.DOTALL))
|
thumbnail = 'http://www.pornovoisines.com/%s' % thumbnail
|
||||||
average_rating = float(self._search_regex(r'Note : (\d+,\d+)',
|
|
||||||
webpage, "average rating").replace(',', '.'))
|
upload_date = unified_strdate(self._search_regex(
|
||||||
comment_count = int(self._search_regex(r'\((\d+)\)', webpage,
|
r'Publié le ([\d-]+)', webpage, 'upload date', fatal=False))
|
||||||
"comment count"))
|
duration = int_or_none(self._search_regex(
|
||||||
|
'Durée (\d+)', webpage, 'duration', fatal=False))
|
||||||
|
view_count = int_or_none(self._search_regex(
|
||||||
|
r'(\d+) vues', webpage, 'view count', fatal=False))
|
||||||
|
average_rating = self._search_regex(
|
||||||
|
r'Note : (\d+,\d+)', webpage, 'average rating', fatal=False)
|
||||||
|
if average_rating:
|
||||||
|
average_rating = float_or_none(average_rating.replace(',', '.'))
|
||||||
|
|
||||||
|
categories = self._html_search_meta(
|
||||||
|
'keywords', webpage, 'categories', fatal=False)
|
||||||
|
if categories:
|
||||||
|
categories = [category.strip() for category in categories.split(',')]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'url': url,
|
'url': video_url,
|
||||||
'title': title,
|
'title': title,
|
||||||
'upload_date': upload_date,
|
|
||||||
'view_count': view_count,
|
|
||||||
'duration': duration,
|
|
||||||
'categories': categories,
|
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'uploader': uploader,
|
'upload_date': upload_date,
|
||||||
|
'duration': duration,
|
||||||
|
'view_count': view_count,
|
||||||
'average_rating': average_rating,
|
'average_rating': average_rating,
|
||||||
'comment_count': comment_count,
|
'categories': categories,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue