]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ccma.py
1 from .common
import InfoExtractor
13 class CCMAIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?ccma\.cat/(?:[^/]+/)*?(?P<type>video|audio)/(?P<id>\d+)'
16 'url': 'http://www.ccma.cat/tv3/alacarta/lespot-de-la-marato-de-tv3/lespot-de-la-marato-de-tv3/video/5630208/',
17 'md5': '7296ca43977c8ea4469e719c609b0871',
21 'title': 'L\'espot de La Marató de TV3',
22 'description': 'md5:f12987f320e2f6e988e9908e4fe97765',
23 'timestamp': 1478608140,
24 'upload_date': '20161108',
28 'url': 'http://www.ccma.cat/catradio/alacarta/programa/el-consell-de-savis-analitza-el-derbi/audio/943685/',
29 'md5': 'fa3e38f269329a278271276330261425',
33 'title': 'El Consell de Savis analitza el derbi',
34 'description': 'md5:e2a3648145f3241cb9c6b4b624033e53',
35 'upload_date': '20170512',
36 'timestamp': 1494622500,
38 'categories': ['Esports'],
41 'url': 'http://www.ccma.cat/tv3/alacarta/crims/crims-josep-tallada-lespereu-me-capitol-1/video/6031387/',
42 'md5': 'b43c3d3486f430f3032b5b160d80cbc3',
46 'title': 'Crims - Josep Talleda, l\'"Espereu-me" (capítol 1)',
47 'description': 'md5:7cbdafb640da9d0d2c0f62bad1e74e60',
48 'timestamp': 1582577700,
49 'upload_date': '20200224',
50 'subtitles': 'mincount:4',
56 def _real_extract(self
, url
):
57 media_type
, media_id
= self
._match
_valid
_url
(url
).groups()
59 media
= self
._download
_json
(
60 'http://dinamics.ccma.cat/pvideo/media.jsp', media_id
, query
={
66 media_url
= media
['media']['url']
67 if isinstance(media_url
, list):
68 for format_
in media_url
:
69 format_url
= url_or_none(format_
.get('file'))
72 label
= format_
.get('label')
73 f
= parse_resolution(label
)
82 'vcodec': 'none' if media_type
== 'audio' else None,
84 self
._sort
_formats
(formats
)
86 informacio
= media
['informacio']
87 title
= informacio
['titol']
88 durada
= informacio
.get('durada') or {}
89 duration
= int_or_none(durada
.get('milisegons'), 1000) or parse_duration(durada
.get('text'))
90 tematica
= try_get(informacio
, lambda x
: x
['tematica']['text'])
92 data_utc
= try_get(informacio
, lambda x
: x
['data_emissio']['utc'])
93 timestamp
= unified_timestamp(data_utc
)
96 subtitols
= media
.get('subtitols') or []
97 if isinstance(subtitols
, dict):
98 subtitols
= [subtitols
]
100 sub_url
= st
.get('url')
102 subtitles
.setdefault(
103 st
.get('iso') or st
.get('text') or 'ca', []).append({
108 imatges
= media
.get('imatges', {})
110 thumbnail_url
= imatges
.get('url')
113 'url': thumbnail_url
,
114 'width': int_or_none(imatges
.get('amplada')),
115 'height': int_or_none(imatges
.get('alcada')),
119 codi_etic
= try_get(informacio
, lambda x
: x
['codi_etic']['id'])
121 codi_etic_s
= codi_etic
.split('_')
122 if len(codi_etic_s
) == 2:
123 if codi_etic_s
[1] == 'TP':
126 age_limit
= int_or_none(codi_etic_s
[1])
131 'description': clean_html(informacio
.get('descripcio')),
132 'duration': duration
,
133 'timestamp': timestamp
,
134 'thumbnails': thumbnails
,
135 'subtitles': subtitles
,
137 'age_limit': age_limit
,
138 'alt_title': informacio
.get('titol_complet'),
139 'episode_number': int_or_none(informacio
.get('capitol')),
140 'categories': [tematica
] if tematica
else None,
141 'series': informacio
.get('programa'),