]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ccma.py
39938c9acbae573b56346093fae599b669a09f7b
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class CCMAIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?ccma\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)'
18 'url': 'http://www.ccma.cat/tv3/alacarta/lespot-de-la-marato-de-tv3/lespot-de-la-marato-de-tv3/video/5630208/',
19 'md5': '7296ca43977c8ea4469e719c609b0871',
23 'title': 'L\'espot de La Marató de TV3',
24 'description': 'md5:f12987f320e2f6e988e9908e4fe97765',
25 'timestamp': 1470918540,
26 'upload_date': '20160811',
29 'url': 'http://www.ccma.cat/catradio/alacarta/programa/el-consell-de-savis-analitza-el-derbi/audio/943685/',
30 'md5': 'fa3e38f269329a278271276330261425',
34 'title': 'El Consell de Savis analitza el derbi',
35 'description': 'md5:e2a3648145f3241cb9c6b4b624033e53',
36 'upload_date': '20171205',
37 'timestamp': 1512507300,
41 def _real_extract(self
, url
):
42 media_type
, media_id
= re
.match(self
._VALID
_URL
, url
).groups()
45 profiles
= ['pc'] if media_type
== 'audio' else ['mobil', 'pc']
46 for i
, profile
in enumerate(profiles
):
47 md
= self
._download
_json
('http://dinamics.ccma.cat/pvideo/media.jsp', media_id
, query
={
54 media_url
= media_data
.get('media', {}).get('url')
61 self
._sort
_formats
(formats
)
63 informacio
= media_data
['informacio']
64 title
= informacio
['titol']
65 durada
= informacio
.get('durada', {})
66 duration
= int_or_none(durada
.get('milisegons'), 1000) or parse_duration(durada
.get('text'))
67 timestamp
= parse_iso8601(informacio
.get('data_emissio', {}).get('utc'))
70 subtitols
= media_data
.get('subtitols', {})
72 sub_url
= subtitols
.get('url')
75 subtitols
.get('iso') or subtitols
.get('text') or 'ca', []).append({
80 imatges
= media_data
.get('imatges', {})
82 thumbnail_url
= imatges
.get('url')
86 'width': int_or_none(imatges
.get('amplada')),
87 'height': int_or_none(imatges
.get('alcada')),
93 'description': clean_html(informacio
.get('descripcio')),
95 'timestamp': timestamp
,
96 'thumnails': thumbnails
,
97 'subtitles': subtitles
,