Repository: yt-dlp
Issue: [TikTok] "unable to download video data: HTTP Error 403: Forbidden" error occurs randomly
Labels: site-bug,triage

### 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

Sweden

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

The error occurs randomly with different videos
If I make a --list-formats request and then try to download the file, it is more likely to download

### 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
[debug] Command-line config: ['-vU', '-f', "mp4[vcodec~='^(avc|h264)'][filesize<30M]/best[ext=mp4][filesize<30M]", 'https://vt.tiktok.com/ZSYQgkUEP/']
[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@2024.07.02 from yt-dlp/yt-dlp [93d33cb29] (pip)
[debug] Python 3.12.3 (CPython x86_64 64bit) - Linux-5.15.0-107-generic-x86_64-with-glibc2.35 (OpenSSL 3.0.2 15 Mar 2022, glibc 2.35)
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.06.02, mutagen-1.47.0, requests-2.32.3, secretstorage-3.3.1, sqlite3-3.37.2, urllib3-2.2.1, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1831 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.07.02 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.07.02 from yt-dlp/yt-dlp)
[vm.tiktok] Extracting URL: https://vt.tiktok.com/ZSYQgkUEP/
[vm.tiktok] ZSYQgkUEP: Downloading webpage
[TikTok] Extracting URL: https://www.tiktok.com/@neskuchnaya_raspa/video/7387362948819209490?_t=8nicoqN67yj&_r=1
[TikTok] 7387362948819209490: Downloading webpage
[debug] [TikTok] Found universal data for rehydration
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[info] 7387362948819209490: Downloading 1 format(s): h264_540p_489591-1
[debug] Invoking http downloader on "https://v19-webapp-prime.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/ok8IDXA2QouIolCCfKVGeDUj5xALgVlAD3fNIg/?a=1988&bti=ODszNWYuMDE6&ch=0&cr=3&dr=0&lr=unwatermarked&cd=0%7C0%7C0%7C&cv=1&br=956&bt=478&cs=0&ds=6&ft=4fUEKMZx8Zmo0hqjK-4jVXr1upWrKsd.&mime_type=video_mp4&qs=4&rc=N2kzZDQ6M2lpaTo2ZzVmPEBpM2k2NXU5cmhsdDMzODczNEBeNWBgXi4yX2AxNmFgLmEyYSNpLS1pMmQ0ci9gLS1kMTFzcw%3D%3D&btag=e00088000&expire=1720047825&l=20240703170315A8FAF12FCCF26F5DF54A&ply_type=2&policy=2&signature=b7ed4bcb6336af26808a754913d03991&tk=tt_chain_token"
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/YoutubeDL.py", line 3479, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/YoutubeDL.py", line 3199, in dl
    return fd.download(name, new_info, subtitle)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/downloader/common.py", line 466, in download
    ret = self.real_download(filename, info_dict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/downloader/http.py", line 369, in real_download
    establish_connection()
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/downloader/http.py", line 120, in establish_connection
    ctx.data = self.ydl.urlopen(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/YoutubeDL.py", line 4161, in urlopen
    return self._request_director.send(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/networking/common.py", line 117, in send
    response = handler.send(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/networking/_helper.py", line 208, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/networking/common.py", line 337, in send
    return self._send(request)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/yt_dlp/networking/_requests.py", line 361, in _send
    raise HTTPError(res, redirect_loop=max_redirects_exceeded)
yt_dlp.networking.exceptions.HTTPError: HTTP Error 403: Forbidden
```