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,
80 'url': 'http://www.cuatro.com/chesterinlove/a-carta/chester-chester_in_love-chester_edu_2_2331030022.html',
81 'only_matching': True,
84 def _parse_content(self
, content
, url
):
85 video_id
= content
['dataMediaId']
86 config
= self
._download
_json
(
87 content
['dataConfig'], video_id
, 'Downloading config JSON')
88 title
= config
['info']['title']
89 services
= config
['services']
90 caronte
= self
._download
_json
(services
['caronte'], video_id
)
91 stream
= caronte
['dls'][0]['stream']
92 headers
= self
.geo_verification_headers()
94 'Content-Type': 'application/json;charset=UTF-8',
95 'Origin': re
.match(r
'https?://[^/]+', url
).group(0),
97 cdn
= self
._download
_json
(
98 caronte
['cerbero'], video_id
, data
=json
.dumps({
99 'bbx': caronte
['bbx'],
100 'gbx': self
._download
_json
(services
['gbx'], video_id
)['gbx'],
101 }).encode(), headers
=headers
)['tokens']['1']['cdn']
102 formats
= self
._extract
_m
3u8_formats
(
103 stream
+ '?' + cdn
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls')
109 'thumbnail': content
.get('dataPoster') or config
.get('poster', {}).get('imageUrl'),
110 'duration': int_or_none(content
.get('dataDuration')),
113 def _real_extract(self
, url
):
114 display_id
= self
._match
_id
(url
)
115 webpage
= self
._download
_webpage
(url
, display_id
)
116 article
= self
._parse
_json
(self
._search
_regex
(
117 r
'window\.\$REACTBASE_STATE\.article(?:_multisite)?\s*=\s*({.+})',
118 webpage
, 'article'), display_id
)['article']
119 title
= article
.get('title')
120 description
= clean_html(article
.get('leadParagraph')) or ''
121 if article
.get('editorialType') != 'VID':
123 body
= [article
.get('opening')]
124 body
.extend(try_get(article
, lambda x
: x
['body'], list) or [])
126 if not isinstance(p
, dict):
128 content
= p
.get('content')
131 type_
= p
.get('type')
132 if type_
== 'paragraph':
133 content_str
= str_or_none(content
)
135 description
+= content_str
137 if type_
== 'video' and isinstance(content
, dict):
138 entries
.append(self
._parse
_content
(content
, url
))
139 return self
.playlist_result(
140 entries
, str_or_none(article
.get('id')), title
, description
)
141 content
= article
['opening']['content']
142 info
= self
._parse
_content
(content
, url
)
144 'description': description
,