aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/ccma.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-04-22 04:55:35 +0700
committerSergey M․ <dstftw@gmail.com>2018-04-22 04:55:35 +0700
commit040c6296bb9da495d37ba134baee996a3a97b64f (patch)
tree871e8cd454b8857d63c6b8ebc2a00984ec949eb0 /youtube_dl/extractor/ccma.py
parenta693386df1957ba03cbf5156a65dd18b2c37ac42 (diff)
[ccma] Fix video extraction (closes #15931)
Diffstat (limited to 'youtube_dl/extractor/ccma.py')
-rw-r--r--youtube_dl/extractor/ccma.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/youtube_dl/extractor/ccma.py b/youtube_dl/extractor/ccma.py
index bec0a825a..07f5206c1 100644
--- a/youtube_dl/extractor/ccma.py
+++ b/youtube_dl/extractor/ccma.py
@@ -4,11 +4,13 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
+from ..compat import compat_str
from ..utils import (
+ clean_html,
int_or_none,
parse_duration,
parse_iso8601,
- clean_html,
+ parse_resolution,
)
@@ -40,34 +42,42 @@ class CCMAIE(InfoExtractor):
def _real_extract(self, url):
media_type, media_id = re.match(self._VALID_URL, url).groups()
- media_data = {}
- formats = []
- profiles = ['pc'] if media_type == 'audio' else ['mobil', 'pc']
- for i, profile in enumerate(profiles):
- md = self._download_json('http://dinamics.ccma.cat/pvideo/media.jsp', media_id, query={
+
+ media = self._download_json(
+ 'http://dinamics.ccma.cat/pvideo/media.jsp', media_id, query={
'media': media_type,
'idint': media_id,
- 'profile': profile,
- }, fatal=False)
- if md:
- media_data = md
- media_url = media_data.get('media', {}).get('url')
- if media_url:
- formats.append({
- 'format_id': profile,
- 'url': media_url,
- 'quality': i,
- })
+ })
+
+ formats = []
+ media_url = media['media']['url']
+ if isinstance(media_url, list):
+ for format_ in media_url:
+ format_url = format_.get('file')
+ if not format_url or not isinstance(format_url, compat_str):
+ continue
+ label = format_.get('label')
+ f = parse_resolution(label)
+ f.update({
+ 'url': format_url,
+ 'format_id': label,
+ })
+ formats.append(f)
+ else:
+ formats.append({
+ 'url': media_url,
+ 'vcodec': 'none' if media_type == 'audio' else None,
+ })
self._sort_formats(formats)
- informacio = media_data['informacio']
+ informacio = media['informacio']
title = informacio['titol']
durada = informacio.get('durada', {})
duration = int_or_none(durada.get('milisegons'), 1000) or parse_duration(durada.get('text'))
timestamp = parse_iso8601(informacio.get('data_emissio', {}).get('utc'))
subtitles = {}
- subtitols = media_data.get('subtitols', {})
+ subtitols = media.get('subtitols', {})
if subtitols:
sub_url = subtitols.get('url')
if sub_url:
@@ -77,7 +87,7 @@ class CCMAIE(InfoExtractor):
})
thumbnails = []
- imatges = media_data.get('imatges', {})
+ imatges = media.get('imatges', {})
if imatges:
thumbnail_url = imatges.get('url')
if thumbnail_url: