Repository: yt-dlp/yt-dlp

Issue:
IPrima broken
### 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'm running yt-dlp version **2023.03.04** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [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

world

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

IPrima website has probably recently changed and yt-dlp does not parse it correctly anymore. Downloading video using directly mpd works.

The video used in this report should be accessible from the whole world (quite surely at least EU).

User account needed, I can provide credentials. (However, only working email is required for a creation of the account, so anybody can create own.)

### 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: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-vU', 'https://www.iprima.cz/serialy/satna/satna/5-epizoda-5']
[debug] User config "C:\Users\jiri\yt-dlp.conf": ['--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36', '--no-check-certificate', '--sponsorblock-remove', 'all', '-o', 'D:\\Downloads\\yt-dlp\\%(autonumber)03d_%(title)s.%(ext)s', '--no-mtime', '--format', 'bestvideo[ext=mp4][height<=1080][fps<=30]+bestaudio[ext=m4a]/best[ext=mp4][height<=1080][fps<=30]/best[height<=1080][fps<=30]/best', '--merge-output-format', 'mkv', '--ffmpeg-location', 'C:\\Apps\\ffmpeg\\bin\\ffmpeg.exe', '--all-subs', '-i', '--compat-options', 'multistreams', '--remux-video', 'mkv', '--add-header', 'accept-language: cs,fi;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6', '--add-header', 'sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"', '--add-header', 'sec-ch-ua-arch: "x86"', '--add-header', 'sec-ch-ua-bitness: "64"', '--add-header', 'sec-ch-ua-full-version: "94.0.4606.71"', '--add-header', 'sec-ch-ua-mobile: ?0', '--add-header', 'sec-ch-ua-model: ""', '--add-header', 'sec-ch-ua-platform: "Windows"', '--add-header', 'sec-ch-ua-platform-version: "10.0.0"', '--add-header', 'sec-fetch-dest: document', '--add-header', 'sec-fetch-mode: navigate', '--add-header', 'sec-fetch-site: none', '--add-header', 'sec-fetch-user: ?1', '--add-header', 'service-worker-navigation-preload: true', '--add-header', 'upgrade-insecure-requests: 1', '--add-header', 'alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', '--add-header', 'cache-control: no-cache, no-store, max-age=0, must-revalidate']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (win_exe)
[debug] Compatibility options: multistreams
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 4.4-full_build-www.gyan.dev (setts), ffprobe 4.4-full_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
Current Build Hash: 5590c57bd0433ed239a2deaaf92e2ad6f37fe50f53664c821575cafe106a9421
yt-dlp is up to date (stable@2023.03.04)
[IPrima] Downloading login page
[IPrima] Logging in
[IPrima] Downloading token
[IPrima] Extracting URL: https://www.iprima.cz/serialy/satna/satna/5-epizoda-5
[IPrima] 5-epizoda-5: Downloading webpage
ERROR: [IPrima] 5-epizoda-5: None: Failed to parse JSON (caused by JSONDecodeError('Expecting \',\' delimiter in \'5","Array"(0),"satna\': line 1 column 498 (char 497)')); 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 "yt_dlp\extractor\common.py", line 694, in extract
  File "yt_dlp\extractor\iprima.py", line 137, in _real_extract
  File "yt_dlp\extractor\common.py", line 1674, in _search_nuxt_data
  File "yt_dlp\extractor\common.py", line 995, in _parse_json
  File "yt_dlp\extractor\common.py", line 978, in __print_error

  File "yt_dlp\utils.py", line 623, in decode
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 353, in raw_decode
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 498 (char 497)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 992, in _parse_json
  File "json\__init__.py", line 370, in loads
  File "yt_dlp\utils.py", line 631, in decode
json.decoder.JSONDecodeError: Expecting ',' delimiter in '5","Array"(0),"satna': line 1 column 498 (char 497)
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/iprima.py b/yt_dlp/extractor/iprima.py
--- a/yt_dlp/extractor/iprima.py
+++ b/yt_dlp/extractor/iprima.py
@@ -134,10 +134,17 @@ def _real_extract(self, url):
         ), webpage, 'real id', group='id', default=None)
 
         if not video_id:
-            nuxt_data = self._search_nuxt_data(webpage, video_id, traverse='data')
+            nuxt_data = self._search_nuxt_data(webpage, video_id, traverse='data', fatal=False)
             video_id = traverse_obj(
                 nuxt_data, (..., 'content', 'additionals', 'videoPlayId', {str}), get_all=False)
 
+        if not video_id:
+            nuxt_data = self._search_json(
+                r'<script[^>]+\bid=["\']__NUXT_DATA__["\'][^>]*>',
+                webpage, 'nuxt data', None, end_pattern=r'</script>', contains_pattern=r'\[(?s:.+)\]')
+
+            video_id = traverse_obj(nuxt_data, lambda _, v: re.fullmatch(r'p\d+', v), get_all=False)
+
         if not video_id:
             self.raise_no_formats('Unable to extract video ID from webpage')
 


Test patch: