Repository: yt-dlp
Issue: ERROR: Invalid IPv6 URL When Accessing banned.video
Labels: site-bug

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

United States

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

**What the problem is:**
When attempting to download various videos from banned.video, I received an error: ERROR: Invalid ipv6 URL. Most of the videos I tried to download worked, but a handful of them do not. I am not logged into the site.

**How it could be fixed**
I'm not sure. I run gentoo and have the -ipv6 USE flag defined globally. There are no ipv6 addresses on this machine and the upstream network/LAN does not support ipv6. The configured kernel doesn't even have ipv6 support. I'm not sure why or how ipv6 is being used at all. I think maybe yt-dlp should force ipv4 when ipv6 isn't an option.

**How your proposed solution would look like**
Force yt-dlp to continue using the ipv4 address or provide a USE flag that disables IPv6 all together (-ipv6)?


### 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
sysop@localhost ~ $ yt-dlp -vU https://banned.video/watch?id=5d066d71a90fbc00123c1d34
[debug] Command-line config: ['-vU', 'https://banned.video/watch?id=5d066d71a90fbc00123c1d34']
[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.05.27 from yt-dlp/yt-dlp [12b248ce6]
[debug] Python 3.12.3 (CPython x86_64 64bit) - Linux-6.6.30-gentoo-x86_64-x86_64-AMD_Ryzen_Threadripper_7970X_32-Cores-with-glibc2.39 (OpenSSL 3.0.13 30 Jan 2024, glibc 2.39)
[debug] exe versions: ffmpeg 6.1.1 (setts), ffprobe 6.1.1
[debug] Optional libraries: certifi-3021.03.16, pycrypto-3.20.0, requests-2.32.1, secretstorage-3.3.3, sqlite3-3.45.3, urllib3-2.2.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests
[debug] Loaded 1820 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.05.27 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.05.27 from yt-dlp/yt-dlp)
[BannedVideo] Extracting URL: https://banned.video/watch?id=5d066d71a90fbc00123c1d34
[BannedVideo] 5d066d71a90fbc00123c1d34: Downloading video metadata
[BannedVideo] 5d066d71a90fbc00123c1d34: Downloading m3u8 information
ERROR: Invalid IPv6 URL
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1606, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1741, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 734, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/bannedvideo.py", line 135, in _real_extract
    formats.extend(self._extract_m3u8_formats(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2014, in _extract_m3u8_formats
    fmts, subs = self._extract_m3u8_formats_and_subtitles(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2048, in _extract_m3u8_formats_and_subtitles
    return self._parse_m3u8_formats_and_subtitles(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2197, in _parse_m3u8_formats_and_subtitles
    manifest_url = format_url(line.strip())
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 2063, in format_url
    return url if re.match(r'^https?://', url) else urllib.parse.urljoin(m3u8_url, url)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/parse.py", line 551, in urljoin
    urlparse(url, bscheme, allow_fragments)
  File "/usr/lib/python3.12/urllib/parse.py", line 395, in urlparse
    splitresult = urlsplit(url, scheme, allow_fragments)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/parse.py", line 497, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

sysop@localhost ~ $
```