]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/telecinco.py
4 from .common
import InfoExtractor
13 class TelecincoIE(InfoExtractor
):
14 IE_DESC
= 'telecinco.es, cuatro.com and mediaset.es'
15 _VALID_URL
= r
'https?://(?:www\.)?(?:telecinco\.es|cuatro\.com|mediaset\.es)/(?:[^/]+/)+(?P<id>.+?)\.html'
18 'url': 'http://www.telecinco.es/robinfood/temporada-01/t01xp14/Bacalao-cocochas-pil-pil_0_1876350223.html',
21 'title': 'Bacalao con kokotxas al pil-pil',
22 'description': 'md5:716caf5601e25c3c5ab6605b1ae71529',
25 'md5': '7ee56d665cfd241c0e6d80fd175068b0',
27 'id': 'JEA5ijCnF6p5W08A1rNKn7',
29 'title': 'Con Martín Berasategui, hacer un bacalao al pil-pil es fácil y divertido',
34 'url': 'http://www.cuatro.com/deportes/futbol/barcelona/Leo_Messi-Champions-Roma_2_2052780128.html',
35 'md5': 'c86fe0d99e3bdb46b7950d38bf6ef12a',
37 'id': 'jn24Od1zGLG4XUZcnUnZB6',
39 'title': '¿Quién es este ex futbolista con el que hablan Leo Messi y Luis Suárez?',
40 'description': 'md5:a62ecb5f1934fc787107d7b9a2262805',
44 'url': 'http://www.mediaset.es/12meses/campanas/doylacara/conlatratanohaytrato/Ayudame-dar-cara-trata-trato_2_1986630220.html',
45 'md5': 'eddb50291df704ce23c74821b995bcac',
47 'id': 'aywerkD2Sv1vGNqq9b85Q2',
49 'title': '#DOYLACARA. Con la trata no hay trato',
50 'description': 'md5:2771356ff7bfad9179c5f5cd954f1477',
54 # video in opening's content
55 'url': 'https://www.telecinco.es/vivalavida/fiorella-sobrina-edmundo-arrocet-entrevista_18_2907195140.html',
58 'title': 'La surrealista entrevista a la sobrina de Edmundo Arrocet: "No puedes venir aquí y tomarnos por tontos"',
59 'description': 'md5:73f340a7320143d37ab895375b2bf13a',
62 'md5': 'adb28c37238b675dad0f042292f209a7',
64 'id': 'TpI2EttSDAReWpJ1o0NVh2',
66 'title': 'La surrealista entrevista a la sobrina de Edmundo Arrocet: "No puedes venir aquí y tomarnos por tontos"',
71 'skip_download': True,
74 'url': 'http://www.telecinco.es/informativos/nacional/Pablo_Iglesias-Informativos_Telecinco-entrevista-Pedro_Piqueras_2_1945155182.html',
75 'only_matching': True,
77 'url': 'http://www.telecinco.es/espanasinirmaslejos/Espana-gran-destino-turistico_2_1240605043.html',
78 'only_matching': True,
81 'url': 'http://www.cuatro.com/chesterinlove/a-carta/chester-chester_in_love-chester_edu_2_2331030022.html',
82 'only_matching': True,
85 def _parse_content(self
, content
, url
):
86 video_id
= content
['dataMediaId']
87 config
= self
._download
_json
(
88 content
['dataConfig'], video_id
, 'Downloading config JSON')
89 title
= config
['info']['title']
90 services
= config
['services']
91 caronte
= self
._download
_json
(services
['caronte'], video_id
)
92 stream
= caronte
['dls'][0]['stream']
93 headers
= self
.geo_verification_headers()
95 'Content-Type': 'application/json;charset=UTF-8',
96 'Origin': re
.match(r
'https?://[^/]+', url
).group(0),
98 cdn
= self
._download
_json
(
99 caronte
['cerbero'], video_id
, data
=json
.dumps({
100 'bbx': caronte
['bbx'],
101 'gbx': self
._download
_json
(services
['gbx'], video_id
)['gbx'],
102 }).encode(), headers
=headers
)['tokens']['1']['cdn']
103 formats
= self
._extract
_m
3u8_formats
(
104 stream
+ '?' + cdn
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls')
110 'thumbnail': content
.get('dataPoster') or config
.get('poster', {}).get('imageUrl'),
111 'duration': int_or_none(content
.get('dataDuration')),
114 def _real_extract(self
, url
):
115 display_id
= self
._match
_id
(url
)
116 webpage
= self
._download
_webpage
(url
, display_id
)
117 article
= self
._parse
_json
(self
._search
_regex
(
118 r
'window\.\$REACTBASE_STATE\.article(?:_multisite)?\s*=\s*({.+})',
119 webpage
, 'article'), display_id
)['article']
120 title
= article
.get('title')
121 description
= clean_html(article
.get('leadParagraph')) or ''
122 if article
.get('editorialType') != 'VID':
124 body
= [article
.get('opening')]
125 body
.extend(try_get(article
, lambda x
: x
['body'], list) or [])
127 if not isinstance(p
, dict):
129 content
= p
.get('content')
132 type_
= p
.get('type')
133 if type_
== 'paragraph':
134 content_str
= str_or_none(content
)
136 description
+= content_str
138 if type_
== 'video' and isinstance(content
, dict):
139 entries
.append(self
._parse
_content
(content
, url
))
140 return self
.playlist_result(
141 entries
, str_or_none(article
.get('id')), title
, description
)
142 content
= article
['opening']['content']
143 info
= self
._parse
_content
(content
, url
)
145 'description': description
,