1 from .common
import InfoExtractor
14 class CCMAIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?ccma\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)'
17 'url': 'http://www.ccma.cat/tv3/alacarta/lespot-de-la-marato-de-tv3/lespot-de-la-marato-de-tv3/video/5630208/',
18 'md5': '7296ca43977c8ea4469e719c609b0871',
22 'title': 'L\'espot de La Marató de TV3',
23 'description': 'md5:f12987f320e2f6e988e9908e4fe97765',
24 'timestamp': 1478608140,
25 'upload_date': '20161108',
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': '20170512',
37 'timestamp': 1494622500,
39 'categories': ['Esports'],
42 'url': 'http://www.ccma.cat/tv3/alacarta/crims/crims-josep-tallada-lespereu-me-capitol-1/video/6031387/',
43 'md5': 'b43c3d3486f430f3032b5b160d80cbc3',
47 'title': 'Crims - Josep Talleda, l\'"Espereu-me" (capítol 1)',
48 'description': 'md5:7cbdafb640da9d0d2c0f62bad1e74e60',
49 'timestamp': 1582577700,
50 'upload_date': '20200224',
51 'subtitles': 'mincount:4',
57 def _real_extract(self
, url
):
58 media_type
, media_id
= self
._match
_valid
_url
(url
).groups()
60 media
= self
._download
_json
(
61 'http://dinamics.ccma.cat/pvideo/media.jsp', media_id
, query
={
68 media_url
= media
['media']['url']
69 if isinstance(media_url
, list):
70 for format_
in media_url
:
71 format_url
= url_or_none(format_
.get('file'))
74 if determine_ext(format_url
) == 'mpd':
75 formats
.extend(self
._extract
_mpd
_formats
(
76 format_url
, media_id
, mpd_id
='dash', fatal
=False))
78 label
= format_
.get('label')
79 f
= parse_resolution(label
)
88 'vcodec': 'none' if media_type
== 'audio' else None,
91 informacio
= media
['informacio']
92 title
= informacio
['titol']
93 durada
= informacio
.get('durada') or {}
94 duration
= int_or_none(durada
.get('milisegons'), 1000) or parse_duration(durada
.get('text'))
95 tematica
= try_get(informacio
, lambda x
: x
['tematica']['text'])
97 data_utc
= try_get(informacio
, lambda x
: x
['data_emissio']['utc'])
98 timestamp
= unified_timestamp(data_utc
)
101 subtitols
= media
.get('subtitols') or []
102 if isinstance(subtitols
, dict):
103 subtitols
= [subtitols
]
105 sub_url
= st
.get('url')
107 subtitles
.setdefault(
108 st
.get('iso') or st
.get('text') or 'ca', []).append({
113 imatges
= media
.get('imatges', {})
115 thumbnail_url
= imatges
.get('url')
118 'url': thumbnail_url
,
119 'width': int_or_none(imatges
.get('amplada')),
120 'height': int_or_none(imatges
.get('alcada')),
124 codi_etic
= try_get(informacio
, lambda x
: x
['codi_etic']['id'])
126 codi_etic_s
= codi_etic
.split('_')
127 if len(codi_etic_s
) == 2:
128 if codi_etic_s
[1] == 'TP':
131 age_limit
= int_or_none(codi_etic_s
[1])
136 'description': clean_html(informacio
.get('descripcio')),
137 'duration': duration
,
138 'timestamp': timestamp
,
139 'thumbnails': thumbnails
,
140 'subtitles': subtitles
,
142 'age_limit': age_limit
,
143 'alt_title': informacio
.get('titol_complet'),
144 'episode_number': int_or_none(informacio
.get('capitol')),
145 'categories': [tematica
] if tematica
else None,
146 'series': informacio
.get('programa'),