[extremetube] Fix extraction (Closes #7163)

pull/2/head
Sergey M․ 9 years ago
parent aa8d2d5be6
commit 50506cb607

@ -3,12 +3,9 @@ from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import compat_urllib_request
compat_parse_qs,
compat_urllib_request,
)
from ..utils import ( from ..utils import (
qualities, int_or_none,
str_to_int, str_to_int,
) )
@ -49,20 +46,36 @@ class ExtremeTubeIE(InfoExtractor):
r'Views:\s*</strong>\s*<span>([\d,\.]+)</span>', r'Views:\s*</strong>\s*<span>([\d,\.]+)</span>',
webpage, 'view count', fatal=False)) webpage, 'view count', fatal=False))
flash_vars = compat_parse_qs(self._search_regex( flash_vars = self._parse_json(
r'<param[^>]+?name="flashvars"[^>]+?value="([^"]+)"', webpage, 'flash vars')) self._search_regex(
r'var\s+flashvars\s*=\s*({.+?});', webpage, 'flash vars'),
video_id)
formats = [] formats = []
quality = qualities(['180p', '240p', '360p', '480p', '720p', '1080p']) for quality_key, video_url in flash_vars.items():
for k, vals in flash_vars.items(): height = int_or_none(self._search_regex(
m = re.match(r'quality_(?P<quality>[0-9]+p)$', k) r'quality_(\d+)[pP]$', quality_key, 'height', default=None))
if m is not None: if not height:
formats.append({ continue
'format_id': m.group('quality'), f = {
'quality': quality(m.group('quality')), 'url': video_url,
'url': vals[0], }
mobj = re.search(
r'/(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', video_url)
if mobj:
height = int(mobj.group('height'))
bitrate = int(mobj.group('bitrate'))
f.update({
'format_id': '%dp-%dk' % (height, bitrate),
'height': height,
'tbr': bitrate,
}) })
else:
f.update({
'format_id': '%dp' % height,
'height': height,
})
formats.append(f)
self._sort_formats(formats) self._sort_formats(formats)
return { return {

Loading…
Cancel
Save