[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / mitele.py
blob76fef337a2eac4acd2b9ad0be0032e95e2709d3a
1 from .telecinco import TelecincoBaseIE
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
8 class MiTeleIE(TelecincoBaseIE):
9 IE_DESC = 'mitele.es'
10 _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
11 _TESTS = [{
12 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
13 'info_dict': {
14 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
15 'ext': 'mp4',
16 'title': 'Diario de La redacción Programa 144',
17 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
18 'series': 'Diario de',
19 'season': 'Season 14',
20 'season_number': 14,
21 'episode': 'Tor, la web invisible',
22 'episode_number': 3,
23 'thumbnail': r're:(?i)^https?://.*\.jpg$',
24 'duration': 2913,
25 'age_limit': 16,
26 'timestamp': 1471209401,
27 'upload_date': '20160814',
29 'skip': 'HTTP Error 404 Not Found',
30 }, {
31 # no explicit title
32 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
33 'info_dict': {
34 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
35 'ext': 'mp4',
36 'title': 'Cuarto Milenio Temporada 6 Programa 226',
37 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
38 'series': 'Cuarto Milenio',
39 'season': 'Season 6',
40 'season_number': 6,
41 'episode': 'Episode 24',
42 'episode_number': 24,
43 'thumbnail': r're:(?i)^https?://.*\.jpg$',
44 'duration': 7313,
45 'age_limit': 12,
46 'timestamp': 1471209021,
47 'upload_date': '20160814',
49 'params': {
50 'skip_download': True,
52 'skip': 'HTTP Error 404 Not Found',
53 }, {
54 'url': 'https://www.mitele.es/programas-tv/horizonte/temporada-5/programa-171-40_013480051/player/',
55 'info_dict': {
56 'id': '7adbe22e-cd41-4787-afa4-36f3da7c2c6f',
57 'ext': 'mp4',
58 'title': 'Horizonte Temporada 5 Programa 171',
59 'description': 'md5:97f1fb712c5ac27e5693a8b3c5c0c6e3',
60 'episode': 'Las Zonas de Bajas Emisiones, a debate',
61 'episode_number': 171,
62 'season': 'Season 5',
63 'season_number': 5,
64 'series': 'Horizonte',
65 'duration': 7012,
66 'upload_date': '20240927',
67 'timestamp': 1727416450,
68 'thumbnail': 'https://album.mediaset.es/eimg/2024/09/27/horizonte-171_9f02.jpg',
69 'age_limit': 12,
71 'params': {'geo_bypass_country': 'ES'},
72 }, {
73 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
74 'only_matching': True,
75 }, {
76 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
77 'only_matching': True,
80 def _real_extract(self, url):
81 display_id = self._match_id(url)
82 webpage = self._download_webpage(url, display_id)
83 pre_player = self._search_json(
84 r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=',
85 webpage, 'Pre Player', display_id)['prePlayer']
86 title = pre_player['title']
87 video_info = self._parse_content(pre_player['video'], url)
88 content = pre_player.get('content') or {}
89 info = content.get('info') or {}
91 video_info.update({
92 'title': title,
93 'description': info.get('synopsis'),
94 'series': content.get('title'),
95 'season_number': int_or_none(info.get('season_number')),
96 'episode': content.get('subtitle'),
97 'episode_number': int_or_none(info.get('episode_number')),
98 'duration': int_or_none(info.get('duration')),
99 'age_limit': int_or_none(info.get('rating')),
100 'timestamp': parse_iso8601(pre_player.get('publishedTime')),
102 return video_info