Repository: yt-dlp
Issue: Download hangs forever for youtube format 18 on some videos
Labels: bug,duplicate,cant-reproduce,regression,core:downloader

### 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

### Provide a description that is worded well enough to be understood

Format 18 is broken for some videos on Youtube. Download for them hangs forever.
For example youtube.com/watch?v=S7So-Kg81j4, youtube.com/watch?v=T82HxfZbQ7Y.
If I cancel the download and relaunch, yt-dlp outputs `Did not get any data blocks`.
Format is really broken, it timeouts after a second in browser too. But I believe it is not an expected behaviour for yt-dlp to hang forever instead of reporting an error and exit.

I've seen some similar issues concerning format 22 (downloading it also resulted in `Didn't get any data blocks`), but not with format 18 and not with infinite hanging.

It seems like issue happens here - https://github.com/yt-dlp/yt-dlp/blob/add96eb9f84cfffe85682bf2fb85135746994ee8/yt_dlp/downloader/http.py#L339 and here - https://github.com/yt-dlp/yt-dlp/blob/add96eb9f84cfffe85682bf2fb85135746994ee8/yt_dlp/downloader/http.py#L374. For some reason yt-dlp thinks that receiving zero bytes is equivalent to NextFragment and doesn't increase retries counter. This results in infinite loop.

Fast workaround is to ban format 18 like format 22. But this can possibly happen with other formats (havn't seen it though).

### 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
Initial try.
yt-dlp --verbose --format 18 youtube.com/watch?v=S7So-Kg81j4
[debug] Command-line config: ['--verbose', '--format', '18', 'youtube.com/watch?v=S7So-Kg81j4']
[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.08.19.232821 from yt-dlp/yt-dlp-nightly-builds [f0bb28504] (pip)
[debug] Python 3.8.18 (CPython x86_64 64bit) - Linux-3.10.0-1160.90.1.el7.x86_64-x86_64-with-glibc2.2.5 (OpenSSL 1.0.2k-fips  26 Jan 2017, glibc 2.17)
[debug] exe versions: ffmpeg 6.0-static (setts), ffprobe 4.3
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.32.3, sqlite3-3.43.2, urllib3-1.26.18, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1830 extractors
[generic] Extracting URL: youtube.com/watch?v=S7So-Kg81j4
WARNING: [generic] The url doesn't specify the protocol, trying with http
[youtube] Extracting URL: http://youtube.com/watch?v=S7So-Kg81j4
[youtube] S7So-Kg81j4: Downloading webpage
[youtube] S7So-Kg81j4: Downloading ios player API JSON
[youtube] S7So-Kg81j4: Downloading web creator player API JSON
[debug] [youtube] Extracting signature function js_6db2bd17_112
[debug] Loading youtube-sigfuncs.js_6db2bd17_112 from cache
[debug] Loading youtube-nsig.6db2bd17 from cache
[debug] [youtube] Decrypted nsig Z0Qlo-b1yFXjX_JF9o9 => akGFBhdw_Wp4_g
[youtube] S7So-Kg81j4: 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] S7So-Kg81j4: Downloading 1 format(s): 18
[debug] Invoking http downloader on "https://rr7---sn-pivhx-n8vs.googlevideo.com/videoplayback?expire=1724259975&ei=J8rFZpm6DpiH0u8PmM3z0Ak&ip=185.187.63.59&id=o-AFeqyuVvQrIX2hXijVdH28lDQSeWYxR2k8k_NPhUsEMR&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=VE&mm=31%2C29&mn=sn-pivhx-n8vs%2Csn-n8v7sney&ms=au%2Crdu&mv=u&mvi=7&pl=24&bui=AQmm2ez7OffO-aj0zcIO8dq8dkqpOkIyWghM7fXAfHh0HLXRGmLi_-t_oGLlJt0aqEJLBlMHX5JZ1izG&spc=Mv1m9k7jFA2Gq130WosFTMD22lbC1TvYvzEX2mjw8vWsJPn46QPwC6g&vprv=1&svpuc=1&mime=video%2Fmp4&ns=VpeXqu3Wkc-D9RO_43J9A9QQ&rqh=1&cnr=14&ratebypass=yes&dur=170.689&lmt=1675718532565591&mt=1724236909&fvip=18&c=WEB_CREATOR&sefc=1&txp=6219224&n=akGFBhdw_Wp4_g&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AGtxev0wRQIgRHinKbjids879d06XlBF_rXqHK-YHfxijnqYP-eicHYCIQCs9ddZaUli_Ojk5McwyjJ5G9c7bLk_l2MalQLyHfpzyA%3D%3D&sig=AJfQdSswRQIhAKfYFriVskQobr8Ub_3wjCbpG3huAuTsfw3Nbl2tCRbcAiBre2S_6X_C80APvqO5oTpXHIZ8zsz-Hlyl5EGDe21NIA%3D%3D"
[download] Destination: 578 Горшкова Анна 13 лет За речкой Школьные годы ДШИ 19 г Кемерово [S7So-Kg81j4].mp4
[download]   1.1% of    6.37MiB at  701.93KiB/s ETA 00:09



Second try (after having something preloaded in the first try).
yt-dlp -vU --format 18 youtube.com/watch?v=S7So-Kg81j4
[debug] Command-line config: ['-vU', '--format', '18', 'youtube.com/watch?v=S7So-Kg81j4']
[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.08.19.232821 from yt-dlp/yt-dlp-nightly-builds [f0bb28504] (pip)
[debug] Python 3.8.18 (CPython x86_64 64bit) - Linux-3.10.0-1160.90.1.el7.x86_64-x86_64-with-glibc2.2.5 (OpenSSL 1.0.2k-fips  26 Jan 2017, glibc 2.17)
[debug] exe versions: ffmpeg 6.0-static (setts), ffprobe 4.3
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.32.3, sqlite3-3.43.2, urllib3-1.26.18, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1830 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.08.19.232821 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.08.19.232821 from yt-dlp/yt-dlp-nightly-builds)
[generic] Extracting URL: youtube.com/watch?v=S7So-Kg81j4
WARNING: [generic] The url doesn't specify the protocol, trying with http
[youtube] Extracting URL: http://youtube.com/watch?v=S7So-Kg81j4
[youtube] S7So-Kg81j4: Downloading webpage
[youtube] S7So-Kg81j4: Downloading ios player API JSON
[youtube] S7So-Kg81j4: Downloading web creator player API JSON
[debug] [youtube] Extracting signature function js_6db2bd17_112
[debug] Loading youtube-sigfuncs.js_6db2bd17_112 from cache
[debug] Loading youtube-nsig.6db2bd17 from cache
[debug] [youtube] Decrypted nsig zGsiXbAya_ywVciUcb5 => 29uSKCZgmox79g
[youtube] S7So-Kg81j4: 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] S7So-Kg81j4: Downloading 1 format(s): 18
[debug] Invoking http downloader on "https://rr7---sn-pivhx-n8vs.googlevideo.com/videoplayback?expire=1724260065&ei=gcrFZufxKtaJ0u8PzICM8AI&ip=185.187.63.59&id=o-APRz-gyxyMtn8e6hellbLIKx4SSgtE47urtNeZ2Dyj3Q&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=VE&mm=31%2C29&mn=sn-pivhx-n8vs%2Csn-n8v7znsz&ms=au%2Crdu&mv=u&mvi=7&pl=24&bui=AQmm2exM9xKAv6JKC1A21dsDFq5v0Iifk28xxZWBhfZtbUfiCS26DJFe9qe06hhzCTpV_Ijp8y8-k4gd&spc=Mv1m9kmWgKq-93XkpzBAlvsuUKgoh8Ngl9rWeikNWnD0yIJ5O0eat-E&vprv=1&svpuc=1&mime=video%2Fmp4&ns=Wp6VEO43lnZdPrGWlcSUNhkQ&rqh=1&cnr=14&ratebypass=yes&dur=170.689&lmt=1675718532565591&mt=1724236909&fvip=18&c=WEB_CREATOR&sefc=1&txp=6219224&n=29uSKCZgmox79g&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AGtxev0wRQIhANlWJ3fhz6Fbx4GDDYH0GvXA5ryo8BEOYMrXsnpbjHNEAiAJ14g43X5yc_uj7hTtVP7l_Yqr3uFy7gThWEyknuIiAQ%3D%3D&sig=AJfQdSswRQIgRI7vLUcwnX1EPxlbm5m2J6n-WTH8qk6gCb9xxYM-bz0CIQDmxq6DXVkLlgZLbTGNFrIs-f4HLyCvIgBWhCGfFA7WvQ%3D%3D"
[download] Resuming download at byte 75018


ERROR: Did not get any data blocks
  File "/home/s.churikov/video_download/venv/bin/yt-dlp", line 8, in <module>
    sys.exit(main())
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/__init__.py", line 1081, in main
    _exit(*variadic(_real_main(argv)))
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/__init__.py", line 1071, in _real_main
    return ydl.download(all_urls)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3607, in download
    self.__download_wrapper(self.extract_info)(
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3582, in wrapper
    res = func(*args, **kwargs)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1615, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1626, in wrapper
    return func(self, *args, **kwargs)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1782, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1861, in process_ie_result
    return self.extract_info(
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1615, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1626, in wrapper
    return func(self, *args, **kwargs)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1782, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1841, in process_ie_result
    ie_result = self.process_video_result(ie_result, download=download)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3015, in process_video_result
    self.process_info(new_info)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 179, in wrapper
    return func(self, *args, **kwargs)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3483, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3203, in dl
    return fd.download(name, new_info, subtitle)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/downloader/common.py", line 466, in download
    ret = self.real_download(filename, info_dict)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/downloader/http.py", line 370, in real_download
    return download()
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/downloader/http.py", line 336, in download
    self.report_error('Did not get any data blocks')
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1092, in report_error
    self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
  File "/home/s.churikov/video_download/venv/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 1020, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())
```