Repository: yt-dlp/yt-dlp
Issue category: Bug Report

[MiTele]: Failed to parse JSON (caused by JSONDecodeError('Extra data in \'d":false}}</script> \': line 1 column 9378 (char 9377)'));
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Spain

### Provide a description that is worded well enough to be understood

Similar to some other allowed websites, mitele is also having an issue (not able to test entire site selection of TV shows) with downloading a TV show. it is geo restricted but user is in Spain. the error follows:
_Failed to parse JSON (caused by JSONDecodeError('Extra data in \'d":false}}</script> \': line 1 column 9378 (char 9377)'));_

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', 'https://www.mitele.es/programas-tv/horizonte/temporada-5/programa-181-40_014084253/player/']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.11.27.232921 from yt-dlp/yt-dlp-nightly-builds [00dcde728] (zip)
[debug] Python 3.10.12 (CPython x86_64 64bit) - Linux-6.8.0-49-generic-x86_64-with-glibc2.35 (OpenSSL 3.0.2 15 Mar 2022, glibc 2.35)
[debug] exe versions: ffmpeg 4.4.2 (setts), ffprobe 4.4.2
[debug] Optional libraries: Cryptodome-3.11.0, brotli-1.0.9, certifi-2020.06.20, mutagen-1.45.1, requests-2.32.3, secretstorage-3.3.1, sqlite3-3.37.2, urllib3-1.26.5, websockets-9.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.11.27.232921 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.11.27.232921 from yt-dlp/yt-dlp-nightly-builds)
[MiTele] Extracting URL: https://www.mitele.es/programas-tv/horizonte/temporada-5/programa-181-40_014084253/player/
[MiTele] programa-181-40_014084253: Downloading webpage
ERROR: [MiTele] programa-181-40_014084253: programa-181-40_014084253: Failed to parse JSON (caused by JSONDecodeError('Extra data in \'d":false}}</script> \': line 1 column 9378 (char 9377)')); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 742, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/mitele.py", line 83, in _real_extract
    pre_player = self._parse_json(self._search_regex(
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1094, in _parse_json
    self.__print_error('Failed to parse JSON' if errnote is None else errnote, fatal, video_id, ve)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1077, in __print_error
    raise ExtractorError(f'{video_id}: {errnote}', cause=err)

  File "/usr/local/bin/yt-dlp/yt_dlp/utils/_utils.py", line 565, in decode
  File "/usr/lib/python3.10/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 9378 (char 9377)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1091, in _parse_json
    return json.loads(
  File "/usr/lib/python3.10/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/local/bin/yt-dlp/yt_dlp/utils/_utils.py", line 573, in decode
json.decoder.JSONDecodeError: Extra data in 'd":false}}</script> ': line 1 column 9378 (char 9377)
```



Functions to edit:
yt_dlp/extractor/mitele.py:MiTeleIE._real_extract

Patch:
diff --git a/yt_dlp/extractor/mitele.py b/yt_dlp/extractor/mitele.py
index 3573a2a3fd72..76fef337a2ea 100644
--- a/yt_dlp/extractor/mitele.py
+++ b/yt_dlp/extractor/mitele.py
@@ -80,9 +80,9 @@ class MiTeleIE(TelecincoBaseIE):
     def _real_extract(self, url):
         display_id = self._match_id(url)
         webpage = self._download_webpage(url, display_id)
-        pre_player = self._parse_json(self._search_regex(
-            r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=\s*({.+})',
-            webpage, 'Pre Player'), display_id)['prePlayer']
+        pre_player = self._search_json(
+            r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=',
+            webpage, 'Pre Player', display_id)['prePlayer']
         title = pre_player['title']
         video_info = self._parse_content(pre_player['video'], url)
         content = pre_player.get('content') or {}