]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ccma.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
17 class CCMAIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?ccma\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)'
20 'url': 'http://www.ccma.cat/tv3/alacarta/lespot-de-la-marato-de-tv3/lespot-de-la-marato-de-tv3/video/5630208/',
21 'md5': '7296ca43977c8ea4469e719c609b0871',
25 'title': 'L\'espot de La Marató de TV3',
26 'description': 'md5:f12987f320e2f6e988e9908e4fe97765',
27 'timestamp': 1470918540,
28 'upload_date': '20160811',
31 'url': 'http://www.ccma.cat/catradio/alacarta/programa/el-consell-de-savis-analitza-el-derbi/audio/943685/',
32 'md5': 'fa3e38f269329a278271276330261425',
36 'title': 'El Consell de Savis analitza el derbi',
37 'description': 'md5:e2a3648145f3241cb9c6b4b624033e53',
38 'upload_date': '20171205',
39 'timestamp': 1512507300,
43 def _real_extract(self
, url
):
44 media_type
, media_id
= re
.match(self
._VALID
_URL
, url
).groups()
46 media
= self
._download
_json
(
47 'http://dinamics.ccma.cat/pvideo/media.jsp', media_id
, query
={
53 media_url
= media
['media']['url']
54 if isinstance(media_url
, list):
55 for format_
in media_url
:
56 format_url
= format_
.get('file')
57 if not format_url
or not isinstance(format_url
, compat_str
):
59 label
= format_
.get('label')
60 f
= parse_resolution(label
)
69 'vcodec': 'none' if media_type
== 'audio' else None,
71 self
._sort
_formats
(formats
)
73 informacio
= media
['informacio']
74 title
= informacio
['titol']
75 durada
= informacio
.get('durada', {})
76 duration
= int_or_none(durada
.get('milisegons'), 1000) or parse_duration(durada
.get('text'))
77 timestamp
= parse_iso8601(informacio
.get('data_emissio', {}).get('utc'))
80 subtitols
= media
.get('subtitols', {})
82 sub_url
= subtitols
.get('url')
85 subtitols
.get('iso') or subtitols
.get('text') or 'ca', []).append({
90 imatges
= media
.get('imatges', {})
92 thumbnail_url
= imatges
.get('url')
96 'width': int_or_none(imatges
.get('amplada')),
97 'height': int_or_none(imatges
.get('alcada')),
103 'description': clean_html(informacio
.get('descripcio')),
104 'duration': duration
,
105 'timestamp': timestamp
,
106 'thumbnails': thumbnails
,
107 'subtitles': subtitles
,