1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2025-02-17 01:17:54 +01:00

[alphaporno] Fix test errors

This also allows selection of different formats when available
This commit is contained in:
Jiří Paleček 2018-05-30 15:14:51 +02:00
parent 9d082e7cb8
commit 4de58cdf6d

View File

@ -1,11 +1,14 @@
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_iso8601,
parse_duration,
parse_filesize,
int_or_none,
js_to_json,
)
@ -35,11 +38,21 @@ class AlphaPornoIE(InfoExtractor):
webpage = self._download_webpage(url, display_id)
video_id = self._search_regex(
r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None)
video_id = re.sub(r'^https?://.*/embed/', '', self._html_search_meta('embedUrl', webpage, 'video id'))
sources = self._parse_json(
self._search_regex(r'sources\s*:\s*(\[[^\]]*\])', webpage, 'source data'), video_id,
transform_source=js_to_json
)
formats = []
for s in sources:
video_url = s['file']
formats.append({
'url': video_url,
'height': int_or_none(re.sub('^(\d+)[pi].*', r'\1', s.get('label') or ''))
})
video_url = self._search_regex(
r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
ext = self._html_search_meta(
'encodingFormat', webpage, 'ext', default='.mp4')[1:]
@ -64,7 +77,6 @@ class AlphaPornoIE(InfoExtractor):
return {
'id': video_id,
'display_id': display_id,
'url': video_url,
'ext': ext,
'title': title,
'thumbnail': thumbnail,
@ -74,4 +86,5 @@ class AlphaPornoIE(InfoExtractor):
'tbr': bitrate,
'categories': categories,
'age_limit': age_limit,
'formats': formats,
}