[playwire] Use _extract_f4m_formats

Related: #9531
This commit is contained in:
Yen Chi Hsuan 2016-05-26 21:43:35 +08:00
parent 0a5685b26f
commit 85b0fe7d64
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30
1 changed files with 6 additions and 21 deletions

View File

@ -4,9 +4,8 @@ import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
xpath_text, dict_get,
float_or_none, float_or_none,
int_or_none,
) )
@ -23,6 +22,7 @@ class PlaywireIE(InfoExtractor):
'duration': 145.94, 'duration': 145.94,
}, },
}, { }, {
# Multiple resolutions while bitrates missing
'url': 'http://cdn.playwire.com/11625/embed/85228.html', 'url': 'http://cdn.playwire.com/11625/embed/85228.html',
'only_matching': True, 'only_matching': True,
}, { }, {
@ -48,25 +48,10 @@ class PlaywireIE(InfoExtractor):
thumbnail = content.get('poster') thumbnail = content.get('poster')
src = content['media']['f4m'] src = content['media']['f4m']
f4m = self._download_xml(src, video_id) formats = self._extract_f4m_formats(src, video_id, assume_f4mv2=True)
base_url = xpath_text(f4m, './{http://ns.adobe.com/f4m/1.0}baseURL', 'base url', fatal=True) for a_format in formats:
formats = [] if not dict_get(a_format, ['tbr', 'width', 'height']):
for media in f4m.findall('./{http://ns.adobe.com/f4m/1.0}media'): a_format['quality'] = 1 if '-hd.' in a_format['url'] else 0
media_url = media.get('url')
if not media_url:
continue
tbr = int_or_none(media.get('bitrate'))
width = int_or_none(media.get('width'))
height = int_or_none(media.get('height'))
f = {
'url': '%s/%s' % (base_url, media.attrib['url']),
'tbr': tbr,
'width': width,
'height': height,
}
if not (tbr or width or height):
f['quality'] = 1 if '-hd.' in media_url else 0
formats.append(f)
self._sort_formats(formats) self._sort_formats(formats)
return { return {