Repository: yt-dlp
Issue: Coalesce adjacent fragments from the same file in the fragment downloader
Labels: enhancement,core:downloader

### Checklist

- [X] I'm reporting a feature request
- [X] I've looked through the [README](https://github.com/yt-dlp/yt-dlp#readme)
- [X] I've verified that I'm running yt-dlp version **2022.04.08** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've searched 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)

### Description

Sometimes, when media are served with a fragment manifest, all the defined fragments are actually adjacent byte ranges from a single file (example: <https://arte-cmafhls.akamaized.net/am/cmaf/100000/100200/100225-000-A/220414121352/100225-000-A.m3u8>).  Currently, yt-dlp downloads all each of those ranges separately; for each byte range the socket has to be opened, the encryption negotiated, the HTTP headers sent, etc. This creates some pretty large overheads due to HTTP and TLS framing, and lowers download speed due to repeatedly going through the TCP slow start phase. But since the ranges are adjacent, it should be possible to download them all together, in bulk. This would save on bandwidth and make the download speed more stable.

At some point we should probably also think about taking advantage of HTTP keep-alive and pipelining, but that would be a separate issue. Coalescing adjacent ranges from the same file seems comparatively easier than that.

~~Please apply 2b22577760833ff17d2a113d041fda41eb1426cf before testing.~~

### Verbose log

```shell
[debug] Invoking downloader on "https://arte-cmafhls.akamaized.net/am/cmaf/100000/100200/100225-000-A/220414121352/medias/100225-000-A_aud_VOF.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 914
[download] Destination: 100225-000-A [100225-000-A].fprogram_audio_0-VOF.mp4
[download]   0.0% of ~29.34MiB at 10.56KiB/s ETA 47:24
[download]   0.0% of ~29.34MiB at 31.36KiB/s ETA 15:57
[download]   0.0% of ~29.34MiB at 72.41KiB/s ETA 06:54
[download]   0.0% of ~29.34MiB at 153.46KiB/s ETA 03:15
[download]   0.1% of ~29.34MiB at 298.84KiB/s ETA 01:40
[download]   0.1% of ~29.34MiB at 312.45KiB/s ETA 01:36
[download]   0.1% of ~29.34MiB at 307.83KiB/s ETA 01:36 (frag 1/914)
[download]   0.1% of ~57.90MiB at  1.70KiB/s ETA 20:17 (frag 1/914) 
[download]   0.1% of ~57.90MiB at  5.08KiB/s ETA 19:12 (frag 1/914)
[download]   0.1% of ~57.90MiB at 11.83KiB/s ETA 17:18 (frag 1/914)
[download]   0.1% of ~57.90MiB at 25.29KiB/s ETA 14:26 (frag 1/914)
[download]   0.1% of ~57.90MiB at 51.94KiB/s ETA 10:52 (frag 1/914)
[download]   0.2% of ~57.90MiB at 102.75KiB/s ETA 07:24 (frag 1/914)
[download]   0.2% of ~57.90MiB at 153.93KiB/s ETA 05:35 (frag 1/914)
[download]   0.2% of ~57.90MiB at 153.55KiB/s ETA 05:35 (frag 2/914)
[download]   0.2% of ~66.95MiB at 21.26KiB/s ETA 06:50 (frag 2/914) 
[download]   0.2% of ~66.95MiB at 62.43KiB/s ETA 06:45 (frag 2/914)
[download]   0.2% of ~66.95MiB at 142.53KiB/s ETA 06:33 (frag 2/914)
[download]   0.2% of ~66.95MiB at 298.62KiB/s ETA 06:12 (frag 2/914)
[download]   0.2% of ~66.95MiB at 539.56KiB/s ETA 05:38 (frag 2/914)
[download]   0.3% of ~66.95MiB at 869.38KiB/s ETA 04:47 (frag 2/914)
[download]   0.3% of ~66.95MiB at  1.01MiB/s ETA 04:12 (frag 2/914) 
[download]   0.3% of ~66.95MiB at 1005.61KiB/s ETA 04:12 (frag 3/914)
[download]   0.3% of ~71.44MiB at 20.52KiB/s ETA 04:44 (frag 3/914)  
[download]   0.3% of ~71.44MiB at 60.09KiB/s ETA 04:42 (frag 3/914)
[download]   0.3% of ~71.44MiB at 136.54KiB/s ETA 04:37 (frag 3/914)
[download]   0.3% of ~71.44MiB at 285.49KiB/s ETA 04:28 (frag 3/914)
[download]   0.3% of ~71.44MiB at 550.92KiB/s ETA 04:13 (frag 3/914)
[download]   0.4% of ~71.44MiB at 838.02KiB/s ETA 03:49 (frag 3/914)
[download]   0.4% of ~71.44MiB at  1.00MiB/s ETA 03:30 (frag 3/914) 
[download]   0.4% of ~71.44MiB at 1001.85KiB/s ETA 03:30 (frag 4/914)
[download]   0.4% of ~74.33MiB at 24.57KiB/s ETA 03:48 (frag 4/914)  
[download]   0.4% of ~74.33MiB at 71.36KiB/s ETA 03:47 (frag 4/914)
[download]   0.4% of ~74.33MiB at 161.54KiB/s ETA 03:44 (frag 4/914)
[download]   0.4% of ~74.33MiB at 335.81KiB/s ETA 03:39 (frag 4/914)
[download]   0.5% of ~74.33MiB at 658.48KiB/s ETA 03:30 (frag 4/914)
[download]   0.5% of ~74.33MiB at 974.31KiB/s ETA 03:16 (frag 4/914)
[download]   0.5% of ~74.33MiB at  1.14MiB/s ETA 03:03 (frag 4/914) 
[download]   0.5% of ~74.33MiB at  1.11MiB/s ETA 03:03 (frag 5/914)
[download]   0.5% of ~76.13MiB at 23.19KiB/s ETA 03:15 (frag 5/914)
[download]   0.5% of ~76.13MiB at 67.26KiB/s ETA 03:15 (frag 5/914)
[download]   0.5% of ~76.13MiB at 152.24KiB/s ETA 03:13 (frag 5/914)
[download]   0.6% of ~76.13MiB at 317.23KiB/s ETA 03:10 (frag 5/914)
[download]   0.6% of ~76.13MiB at 608.02KiB/s ETA 03:04 (frag 5/914)
[download]   0.6% of ~76.13MiB at 831.13KiB/s ETA 02:55 (frag 5/914)
[download]   0.7% of ~76.13MiB at 652.60KiB/s ETA 02:55 (frag 5/914)
[download]   0.7% of ~76.13MiB at 645.97KiB/s ETA 02:55 (frag 6/914)
[download]   0.6% of ~77.40MiB at  9.23KiB/s ETA 03:14 (frag 6/914) 
[download]   0.6% of ~77.40MiB at 27.39KiB/s ETA 03:14 (frag 6/914)
[download]   0.7% of ~77.40MiB at 63.24KiB/s ETA 03:12 (frag 6/914)
[download]   0.7% of ~77.40MiB at 133.99KiB/s ETA 03:10 (frag 6/914)
[download]   0.7% of ~77.40MiB at 271.21KiB/s ETA 03:04 (frag 6/914)
[download]   0.7% of ~77.40MiB at 474.75KiB/s ETA 02:56 (frag 6/914)
[download]   0.8% of ~77.40MiB at 605.57KiB/s ETA 02:50 (frag 6/914)
[download]   0.8% of ~77.40MiB at 599.56KiB/s ETA 02:50 (frag 7/914)
[download]   0.8% of ~78.35MiB at 22.32KiB/s ETA 02:58 (frag 7/914) 
[download]   0.8% of ~78.35MiB at 64.96KiB/s ETA 02:58 (frag 7/914)
[download]   0.8% of ~78.35MiB at 146.45KiB/s ETA 02:57 (frag 7/914)
[download]   0.8% of ~78.35MiB at 304.43KiB/s ETA 02:55 (frag 7/914)
[download]   0.8% of ~78.35MiB at 589.57KiB/s ETA 02:51 (frag 7/914)
[download]   0.8% of ~78.35MiB at 918.65KiB/s ETA 02:44 (frag 7/914)
[download]   0.9% of ~78.35MiB at 1022.51KiB/s ETA 02:39 (frag 7/914)
```