1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-09 11:13:32 +08:00

[ccma] parse resolution from utils, ensure only existing urls are appended.

This commit is contained in:
Andres 2018-04-08 21:27:27 +02:00
parent dfaae7e7eb
commit a35a69bece

View File

@ -10,6 +10,7 @@ from ..utils import (
parse_duration,
parse_iso8601,
clean_html,
parse_resolution
)
@ -44,7 +45,7 @@ class CCMAIE(InfoExtractor):
media_data = {}
formats = []
profiles = ['pc'] if media_type == 'audio' else ['mobil', 'pc']
for i, profile in enumerate(profiles):
for profile in profiles:
md = self._download_json('http://dinamics.ccma.cat/pvideo/media.jsp', media_id, query={
'media': media_type,
'idint': media_id,
@ -53,28 +54,21 @@ class CCMAIE(InfoExtractor):
if md:
media_data = md
media_url = media_data.get('media', {}).get('url')
ext = media_data.get('media', {}).get('format')
if ext:
ext = ext.lower()
if media_url and isinstance(media_url, list):
for _url in media_url:
if 'label' in _url:
height = int_or_none(_url.get('label').replace('p', ''))
else:
height = None
resolution = parse_resolution(_url.get('label'))
if _url.get('file'):
formats.append({
'format_id': profile,
'url': _url.get('file'),
'height': height,
'ext': ext
'height': resolution.get('height'),
})
elif media_url and isinstance(media_url, compat_str):
formats.append({
'format_id': profile,
'url': media_url,
'ext': ext
})
self._sort_formats(formats)