diff options
author | Remita Amine <remitamine@gmail.com> | 2016-07-06 09:11:46 +0100 |
---|---|---|
committer | Remita Amine <remitamine@gmail.com> | 2016-07-06 09:11:46 +0100 |
commit | ab49d7a9fae08763de549f85ba138b22f9122a99 (patch) | |
tree | d4a2c796088234b9553db074ccbd5ae1752a540c /youtube_dl/extractor/amp.py | |
parent | b4173f1551c47f64745cb91451c46891e2aaac16 (diff) |
use mimetype2ext to determine manifest ext in multiple extractors
Diffstat (limited to 'youtube_dl/extractor/amp.py')
-rw-r--r-- | youtube_dl/extractor/amp.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/youtube_dl/extractor/amp.py b/youtube_dl/extractor/amp.py index 8545681be..283736fc5 100644 --- a/youtube_dl/extractor/amp.py +++ b/youtube_dl/extractor/amp.py @@ -5,6 +5,8 @@ from .common import InfoExtractor from ..utils import ( int_or_none, parse_iso8601, + mimetype2ext, + determine_ext, ) @@ -50,21 +52,25 @@ class AMPIE(InfoExtractor): if isinstance(media_content, dict): media_content = [media_content] for media_data in media_content: - media = media_data['@attributes'] - media_type = media['type'] - if media_type in ('video/f4m', 'application/f4m+xml'): + media = media_data.get('@attributes', {}) + media_url = media.get('url') + if not media_url: + continue + ext = mimetype2ext(media.get('type')) or determne_ext(media_url) + if ext == 'f4m': formats.extend(self._extract_f4m_formats( - media['url'] + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', + media_url + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124', video_id, f4m_id='hds', fatal=False)) - elif media_type == 'application/x-mpegURL': + elif ext == 'm3u8': formats.extend(self._extract_m3u8_formats( - media['url'], video_id, 'mp4', m3u8_id='hls', fatal=False)) + media_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) else: formats.append({ 'format_id': media_data.get('media-category', {}).get('@attributes', {}).get('label'), 'url': media['url'], 'tbr': int_or_none(media.get('bitrate')), 'filesize': int_or_none(media.get('fileSize')), + 'ext': ext, }) self._sort_formats(formats) |