Repository: yt-dlp/yt-dlp

Issue:
[youtube] YouTube said: ERROR - Precondition check failed - HTTP Error 400: Bad Request
### 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

Global

### Provide a description that is worded well enough to be understood

It started from several days ago, when "--cookies-from-browser chrome" were given to yt-dlp, some warnings will occur. But it can still finish downloading, though I didn't test for links which need a premium account to watch. (I don't have a premium account. I use a bat file which will automatically add these parameters because I'm not only using this tool for YouTube.)

The following output is with -F parameter to list out all available formats, but designated format (like -f 137+140/313+251) will lead to the same warning output.

~~But if no cookies parameters are given, the warnings will not occur.~~

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] 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
yt-dlp --cookies-from-browser chrome -F "https://www.youtube.com/watch?v=UK4BVBhZRm8" --verbose
[debug] Command-line config: ['--cookies-from-browser', 'chrome', '-F', 'https://www.youtube.com/watch?v=UK4BVBhZRm8', '--verbose']
Extracting cookies from chrome
[debug] Extracting cookies from: "C:\Users\[Username]\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies"
[debug] Found local state file at "C:\Users\[Username]\AppData\Local\Google\Chrome\User Data\Local State"
Extracted 362 cookies from chrome
[debug] cookie version breakdown: {'v10': 362, 'other': 0, 'unencrypted': 0}
[debug] Encodings: locale cp936, fs utf-8, pref cp936, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.12.30 from yt-dlp/yt-dlp [f10589e34] (win_exe)
[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 2024-02-15-git-a2cfd6062c-full_build-www.gyan.dev (setts), ffprobe 2024-02-15-git-a2cfd6062c-full_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.19.1, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.1.0, websockets-12.0
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1798 extractors
[youtube] Extracting URL: https://www.youtube.com/watch?v=UK4BVBhZRm8
[youtube] UK4BVBhZRm8: Downloading webpage
[debug] [youtube] Extracted SAPISID cookie
[youtube] UK4BVBhZRm8: Downloading ios player API JSON
[youtube] UK4BVBhZRm8: Downloading android player API JSON
WARNING: [youtube] YouTube said: ERROR - Precondition check failed.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (1/3)...
[youtube] UK4BVBhZRm8: Downloading android player API JSON
WARNING: [youtube] YouTube said: ERROR - Precondition check failed.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (2/3)...
[youtube] UK4BVBhZRm8: Downloading android player API JSON
WARNING: [youtube] YouTube said: ERROR - Precondition check failed.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (3/3)...
[youtube] UK4BVBhZRm8: Downloading android player API JSON
WARNING: [youtube] YouTube said: ERROR - Precondition check failed.
WARNING: [youtube] Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>); 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
[debug] Loading youtube-nsig.95cde7ed from cache
[debug] [youtube] Decrypted nsig 5bTotIK1gFjNgIBv => FtvvoGjPVzKbSA
[debug] Loading youtube-nsig.95cde7ed from cache
[debug] [youtube] Decrypted nsig bBGZL444AU1fsaOX => o-GMGuNTrOkj-g
[youtube] UK4BVBhZRm8: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] Available formats for UK4BVBhZRm8:
ID  EXT   RESOLUTION FPS CH │   FILESIZE    TBR PROTO │ VCODEC           VBR ACODEC      ABR ASR MORE INFO
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

sb3 mhtml 48x27        1    │                   mhtml │ images                                   storyboard
sb2 mhtml 85x45        1    │                   mhtml │ images                                   storyboard
sb1 mhtml 170x90       1    │                   mhtml │ images                                   storyboard
sb0 mhtml 341x180      1    │                   mhtml │ images                                   storyboard
233 mp4   audio only        │                   m3u8  │ audio only           unknown             Default, IOS
234 mp4   audio only        │                   m3u8  │ audio only           unknown             Default, IOS
139 m4a   audio only      2 │    1.02MiB    49k https │ audio only           mp4a.40.5   49k 22k low, IOS, m4a_dash
249 webm  audio only      2 │    1.02MiB    49k https │ audio only           opus        49k 48k low, WEB, webm_dash
250 webm  audio only      2 │    1.25MiB    60k https │ audio only           opus        60k 48k low, WEB, webm_dash
140 m4a   audio only      2 │    2.71MiB   130k https │ audio only           mp4a.40.2  130k 44k medium, IOS, m4a_dash
251 webm  audio only      2 │    2.35MiB   112k https │ audio only           opus       112k 48k medium, WEB, webm_dash
602 mp4   256x136     15    │ ~  2.15MiB   100k m3u8  │ vp09.00.10.08   100k video only          IOS
269 mp4   256x136     30    │ ~  4.13MiB   192k m3u8  │ avc1.4D400C     192k video only          IOS
160 mp4   256x136     30    │    2.15MiB   103k https │ avc1.4D400C     103k video only          144p, IOS, mp4_dash
603 mp4   256x136     30    │ ~  3.92MiB   182k m3u8  │ vp09.00.11.08   182k video only          IOS
278 webm  256x136     30    │    1.91MiB    91k https │ vp09.00.11.08    91k video only          144p, IOS, webm_dash
229 mp4   426x224     30    │ ~  7.15MiB   333k m3u8  │ avc1.4D400D     333k video only          IOS
133 mp4   426x224     30    │    4.43MiB   212k https │ avc1.4D400D     212k video only          240p, IOS, mp4_dash
604 mp4   426x224     30    │ ~  7.08MiB   330k m3u8  │ vp09.00.20.08   330k video only          IOS
242 webm  426x224     30    │    3.77MiB   180k https │ vp09.00.20.08   180k video only          240p, IOS, webm_dash
230 mp4   640x338     30    │ ~ 17.52MiB   815k m3u8  │ avc1.4D401E     815k video only          IOS
134 mp4   640x338     30    │    8.96MiB   428k https │ avc1.4D401E     428k video only          360p, IOS, mp4_dash
18  mp4   640x338     30  2 │   10.94MiB   523k https │ avc1.42001E          mp4a.40.2       44k 360p, WEB
605 mp4   640x338     30    │ ~ 12.50MiB   582k m3u8  │ vp09.00.21.08   582k video only          IOS
243 webm  640x338     30    │    5.99MiB   286k https │ vp09.00.21.08   286k video only          360p, IOS, webm_dash
231 mp4   854x450     30    │ ~ 29.91MiB  1392k m3u8  │ avc1.4D401F    1392k video only          IOS
135 mp4   854x450     30    │   16.81MiB   804k https │ avc1.4D401F     804k video only          480p, IOS, mp4_dash
606 mp4   854x450     30    │ ~ 20.42MiB   950k m3u8  │ vp09.00.30.08   950k video only          IOS
244 webm  854x450     30    │   10.51MiB   503k https │ vp09.00.30.08   503k video only          480p, IOS, webm_dash
22  mp4   1280x676    30  2 │ ≈ 35.73MiB  1663k https │ avc1.64001F          mp4a.40.2       44k 720p, WEB
136 mp4   1280x676    30    │   32.10MiB  1535k https │ avc1.64001f    1535k video only          720p, WEB, mp4_dash
247 webm  1280x676    30    │   18.09MiB   865k https │ vp9             865k video only          720p, WEB, webm_dash
311 mp4   1280x676    60    │ ~ 88.97MiB  4141k m3u8  │ avc1.640020    4141k video only          IOS
298 mp4   1280x676    60    │   46.17MiB  2207k https │ avc1.640020    2207k video only          720p60, IOS, mp4_dash
612 mp4   1280x676    60    │ ~ 61.69MiB  2871k m3u8  │ vp09.00.40.08  2871k video only          IOS
302 webm  1280x676    60    │   36.10MiB  1726k https │ vp09.00.40.08  1726k video only          720p60, IOS, webm_dash
312 mp4   1920x1012   60    │ ~136.17MiB  6338k m3u8  │ avc1.64002A    6338k video only          IOS
299 mp4   1920x1012   60    │   79.52MiB  3802k https │ avc1.64002A    3802k video only          1080p60, IOS, mp4_dash
617 mp4   1920x1012   60    │ ~100.45MiB  4675k m3u8  │ vp09.00.41.08  4675k video only          IOS
303 webm  1920x1012   60    │   66.69MiB  3189k https │ vp09.00.41.08  3189k video only          1080p60, IOS, webm_dash

623 mp4   2560x1350   60    │ ~231.59MiB 10779k m3u8  │ vp09.00.50.08 10779k video only          IOS
308 webm  2560x1350   60    │  173.84MiB  8311k https │ vp09.00.50.08  8311k video only          1440p60, IOS, webm_dash

628 mp4   3840x2026   60    │ ~443.94MiB 20663k m3u8  │ vp09.00.51.08 20663k video only          IOS
315 webm  3840x2026   60    │  331.78MiB 15862k https │ vp09.00.51.08 15862k video only          2160p60, IOS, webm_dash
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -114,9 +114,9 @@
         'INNERTUBE_CONTEXT': {
             'client': {
                 'clientName': 'ANDROID',
-                'clientVersion': '17.31.35',
+                'clientVersion': '18.11.34',
                 'androidSdkVersion': 30,
-                'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip'
+                'userAgent': 'com.google.android.youtube/18.11.34 (Linux; U; Android 11) gzip'
             }
         },
         'INNERTUBE_CONTEXT_CLIENT_NAME': 3,
@@ -127,9 +127,9 @@
         'INNERTUBE_CONTEXT': {
             'client': {
                 'clientName': 'ANDROID_EMBEDDED_PLAYER',
-                'clientVersion': '17.31.35',
+                'clientVersion': '18.11.34',
                 'androidSdkVersion': 30,
-                'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip'
+                'userAgent': 'com.google.android.youtube/18.11.34 (Linux; U; Android 11) gzip'
             },
         },
         'INNERTUBE_CONTEXT_CLIENT_NAME': 55,
@@ -168,9 +168,9 @@
         'INNERTUBE_CONTEXT': {
             'client': {
                 'clientName': 'IOS',
-                'clientVersion': '17.33.2',
+                'clientVersion': '18.11.34',
                 'deviceModel': 'iPhone14,3',
-                'userAgent': 'com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
+                'userAgent': 'com.google.ios.youtube/18.11.34 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
             }
         },
         'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
@@ -180,9 +180,9 @@
         'INNERTUBE_CONTEXT': {
             'client': {
                 'clientName': 'IOS_MESSAGES_EXTENSION',
-                'clientVersion': '17.33.2',
+                'clientVersion': '18.11.34',
                 'deviceModel': 'iPhone14,3',
-                'userAgent': 'com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
+                'userAgent': 'com.google.ios.youtube/18.11.34 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)'
             },
         },
         'INNERTUBE_CONTEXT_CLIENT_NAME': 66,


Test patch: