Repository: yt-dlp/yt-dlp

Issue:
[youtube] `--extractor-retries infinite` error: `'float' object cannot be interpreted as an integer`
### 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.10.07** ([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)
- [ ] 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

_No response_

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

YouTube videos can't be downloaded in conjunction with `--extractor-retries infinite` anymore.
This error must have been introduced with the last update since it doesn't occur when using the previous version.

### 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', '--ffmpeg-location', 'C:\\Program Files\\ffmpeg-master-latest-win64-gpl\\bin', '--extractor-retries', 'infinite', 'BaW_jenozKc']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version stable@2023.10.07 [377e85a17] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-8.1-6.3.9600-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-110355-gb56aca9b42-20230423 (setts), ffprobe N-110355-gb56aca9b42-20230423
[debug] Optional libraries: Cryptodome-3.19.0, brotli-1.1.0, certifi-2023.07.22, mutagen-1.47.0, sqlite3-3.35.5, websockets-11.0.3
[debug] Proxy map: {}
[debug] Loaded 1886 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.10.07, Current version: stable@2023.10.07
Current Build Hash: 7c809be9ad981b2a057bd60d766a9dffb1e88ddea6a9530c416f4741bc297364
yt-dlp is up to date (stable@2023.10.07)
[youtube] Extracting URL: BaW_jenozKc
[youtube] BaW_jenozKc: Downloading webpage
ERROR: 'float' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1567, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1702, in __extract_info
  File "yt_dlp\extractor\common.py", line 715, in extract
  File "yt_dlp\extractor\youtube.py", line 4070, in _real_extract
  File "yt_dlp\extractor\youtube.py", line 4034, in _download_player_responses
  File "yt_dlp\extractor\youtube.py", line 3690, in _extract_player_responses
  File "yt_dlp\extractor\youtube.py", line 3610, in _extract_player_response
  File "yt_dlp\extractor\youtube.py", line 950, in _extract_response
TypeError: 'float' object cannot be interpreted as an integer


# Using yt-dlp 2023.09.24
[debug] Command-line config: ['-v', '--ffmpeg-location', 'C:\\Program Files\\ffmpeg-master-latest-win64-gpl\\bin', '--extractor-retries', 'infinite', 'BaW_jenozKc']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version stable@2023.09.24 [088add956] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-8.1-6.3.9600-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-110355-gb56aca9b42-20230423 (setts), ffprobe N-110355-gb56aca9b42-20230423
[debug] Optional libraries: Cryptodome-3.19.0, brotli-1.1.0, certifi-2023.07.22, mutagen-1.47.0, sqlite3-3.35.5, websockets-11.0.3
[debug] Proxy map: {}
[debug] Loaded 1886 extractors
[youtube] Extracting URL: BaW_jenozKc
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading ios player API JSON
[youtube] BaW_jenozKc: Downloading android player API JSON
[youtube] BaW_jenozKc: 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
[debug] Default format spec: bestvideo*+bestaudio/best
[info] BaW_jenozKc: Downloading 1 format(s): 248+251
[debug] Invoking http downloader on "https://rr2---sn-jncqx-i5he.googlevideo.com/videoplayback?expire=1697004044&ei=rOUlZZbGB4iWgAeEgJSQBw&ip=<REDACTED>&id=o-AIF-kFY11i1-0SkIv7D7gLITRAsjdETesy_BqqpcsNCa&itag=248&source=youtube&requiressl=yes&mh=Rf&mm=31%2C29&mn=sn-jncqx-i5he%2Csn-i5heen7d&ms=au%2Crdu&mv=m&mvi=2&pcm2cms=yes&pl=24&initcwndbps=2592500&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=988479&dur=9.833&lmt=1544741703689523&mt=1696982033&fvip=2&keepalive=yes&fexp=24007246&beids=24350018&c=IOS&txp=5432432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AGM4YrMwRAIgFbSoM_CWMCCXmaCsxOke9rVgEh7Any1xwa0Q88h6r7sCIC0TCO6vpMSuextsOvtYaK3SxyzChGoYaTvFWjmRg0f-&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AK1ks_kwRQIgXM_zveiandp3cT_Bc8CXwUI4lutrWuO9EETvv4ZbtGUCIQDQfqp1-kAG0fTpuxTmwE22tw6vRWRXomlLE0lVfKU3qQ%3D%3D"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: youtube-dl test video "'??ä??? [BaW_jenozKc].f248.webm
[download] 100% of  965.31KiB in 00:00:00 at 2.64MiB/s
[debug] Invoking http downloader on "https://rr2---sn-jncqx-i5he.googlevideo.com/videoplayback?expire=1697004044&ei=rOUlZeDqFJO9x_APs-C2oA0&ip=<REDACTED>&id=o-AH_xmrBcENf-uNSvB_hb-a1ByKxdRank9ZHLhVFxtvrk&itag=251&source=youtube&requiressl=yes&mh=Rf&mm=31%2C29&mn=sn-jncqx-i5he%2Csn-i5h7lner&ms=au%2Crdu&mv=m&mvi=2&pl=24&initcwndbps=2592500&spc=UWF9f10fVgjiGXXNYjcnNAcQIWH9a7Q&vprv=1&svpuc=1&mime=audio%2Fwebm&gir=yes&clen=142292&dur=9.841&lmt=1506055557712479&mt=1696982033&fvip=4&keepalive=yes&fexp=24007246&beids=24350018&c=ANDROID&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AGM4YrMwRQIgPgBVnXKEPGpHwl1MDUqY0HXnUv9hcWWWZGSVjwUUMuMCIQD7f2gl6KERYnukEbqjy8oKn7ER3BSIqeZjDJCExoPIMQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AK1ks_kwRAIgZcUPmPwWOdlLkP5l0D_-CqnsVHZQx5odXsFQygANKS0CIHUSFkLLhjxFaoTWOUTta7MgX5qY8cODI4w3GGtQauGl"
[download] Destination: youtube-dl test video "'??ä??? [BaW_jenozKc].f251.webm
[download] 100% of  138.96KiB in 00:00:00 at 773.35KiB/s
[Merger] Merging formats into "youtube-dl test video "'??ä??? [BaW_jenozKc].webm"
[debug] ffmpeg command line: "C:\Program Files\ffmpeg-master-latest-win64-gpl\bin\ffmpeg" -y -loglevel "repeat+info" -i "file:youtube-dl test video "'??ä??? [BaW_jenozKc].f248.webm" -i "file:youtube-dl test video "'??ä??? [BaW_jenozKc].f251.webm" -c copy -map "0:v:0" -map "1:a:0" -movflags "+faststart" "file:youtube-dl test video "'??ä??? [BaW_jenozKc].temp.webm"
Deleting original file youtube-dl test video "'??ä??? [BaW_jenozKc].f248.webm (pass -k to keep)
Deleting original file youtube-dl test video "'??ä??? [BaW_jenozKc].f251.webm (pass -k to keep)
```



Discussion:
cc @Grub4K 
Git bisect says it's a regression in https://github.com/yt-dlp/yt-dlp/commit/eb5bdbfa70126c7d5355cc0954b63720522e462c
`range(inf+inf+1)` doesnt work. We can use `frange` or just `itertools.count` instead

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
@@ -947,7 +947,10 @@ def _extract_response(self, item_id, query, note='Downloading API JSON', headers
         icd_rm = next(icd_retries)
         main_retries = iter(self.RetryManager())
         main_rm = next(main_retries)
-        for _ in range(main_rm.retries + icd_rm.retries + 1):
+        # Manual retry loop for multiple RetryManagers
+        # The proper RetryManager MUST be advanced after an error
+        # and it's result MUST be checked if the manager is non fatal
+        while True:
             try:
                 response = self._call_api(
                     ep=ep, fatal=True, headers=headers,


Test patch: