[tube8] Fix extraction and extract all formats (Closes #8281)
This commit is contained in:
parent
56aa074538
commit
27b83249c9
1 changed files with 23 additions and 11 deletions
|
@ -1,10 +1,9 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_urllib_parse_urlparse
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
|
@ -44,14 +43,28 @@ class Tube8IE(InfoExtractor):
|
||||||
req.add_header('Cookie', 'age_verified=1')
|
req.add_header('Cookie', 'age_verified=1')
|
||||||
webpage = self._download_webpage(req, display_id)
|
webpage = self._download_webpage(req, display_id)
|
||||||
|
|
||||||
flashvars = json.loads(self._html_search_regex(
|
flashvars = self._parse_json(
|
||||||
r'flashvars\s*=\s*({.+?});\r?\n', webpage, 'flashvars'))
|
self._search_regex(
|
||||||
|
r'flashvars\s*=\s*({.+?});\r?\n', webpage, 'flashvars'),
|
||||||
|
video_id)
|
||||||
|
|
||||||
video_url = flashvars['video_url']
|
formats = []
|
||||||
|
for key, video_url in flashvars.items():
|
||||||
|
if not isinstance(video_url, compat_str) or not video_url.startswith('http'):
|
||||||
|
continue
|
||||||
|
height = self._search_regex(
|
||||||
|
r'quality_(\d+)[pP]', key, 'height', default=None)
|
||||||
|
if not height:
|
||||||
|
continue
|
||||||
if flashvars.get('encrypted') is True:
|
if flashvars.get('encrypted') is True:
|
||||||
video_url = aes_decrypt_text(video_url, flashvars['video_title'], 32).decode('utf-8')
|
video_url = aes_decrypt_text(
|
||||||
path = compat_urllib_parse_urlparse(video_url).path
|
video_url, flashvars['video_title'], 32).decode('utf-8')
|
||||||
format_id = '-'.join(path.split('/')[4].split('_')[:2])
|
formats.append({
|
||||||
|
'url': video_url,
|
||||||
|
'format_id': '%sp' % height,
|
||||||
|
'height': int(height),
|
||||||
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnail = flashvars.get('image_url')
|
thumbnail = flashvars.get('image_url')
|
||||||
|
|
||||||
|
@ -79,15 +92,14 @@ class Tube8IE(InfoExtractor):
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'url': video_url,
|
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'format_id': format_id,
|
|
||||||
'view_count': view_count,
|
'view_count': view_count,
|
||||||
'like_count': like_count,
|
'like_count': like_count,
|
||||||
'dislike_count': dislike_count,
|
'dislike_count': dislike_count,
|
||||||
'comment_count': comment_count,
|
'comment_count': comment_count,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue