Repository: yt-dlp
Issue: [PeerTube] Uses port 443 (instead of port 80) for Tor .onion PeerTube URLs
Labels: site-bug,triage

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I'm running yt-dlp version **2022.03.08.1**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#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 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

When trying to download a video from a PeerTube powered website hosted as a Tor hidden service (.onion), it tries to connect to it using port 443, which leads to failure, because port 80 is expected.

Example URL: `http://dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion/w/mirK3SbmFLNNC41tc5sXMf`

The relevant part of the verbose log:

```
[debug] [PeerTube] Extracting URL: peertube:dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:mirK3SbmFLNNC41tc5sXMf
[PeerTube] mirK3SbmFLNNC41tc5sXMf: Downloading video JSON
[proxychains] Random chain  ...  127.0.0.1:9050  ...  dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:443 <--socket error or timeout!
ERROR: [PeerTube] mirK3SbmFLNNC41tc5sXMf: Unable to download webpage: <urlopen error [Errno 111] Connection refused> (caused by URLError(ConnectionRefusedError(111, 'Connection refused')))
```

The solution would be to detect `.onion` URLs and connect to them via port 80.

With the equivalent clearnet URL (`https://dollarvigilante.tv/w/mirK3SbmFLNNC41tc5sXMf`), `yt-dlp` works as expected.

### Verbose log

```shell
% proxychains yt-dlp -vU http://dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion/w/mirK3SbmFLNNC41tc5sXMf
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.16
[debug] Command-line config: ['-vU', 'http://dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion/w/mirK3SbmFLNNC41tc5sXMf']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.03.08.1 [c0c2c57d3]
[debug] Lazy loading extractors is disabled
[debug] Python version 3.10.4 (CPython 64bit) - Linux-5.16.18-hardened1-1-hardened-x86_64-with-glibc2.35
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 5.0 (setts), ffprobe 5.0, rtmpdump 2.4
[debug] Optional libraries: brotli, Crypto, secretstorage, sqlite, websockets
[debug] Proxy map: {}
[proxychains] Random chain  ...  127.0.0.1:9050  ...  api.github.com:443  ...  OK
Latest version: 2022.03.08.1, Current version: 2022.03.08.1
yt-dlp is up to date (2022.03.08.1)
[debug] [generic] Extracting URL: http://dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion/w/mirK3SbmFLNNC41tc5sXMf
[generic] mirK3SbmFLNNC41tc5sXMf: Requesting header
[proxychains] Random chain  ...  127.0.0.1:9050  ...  dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:80  ...  OK
WARNING: [generic] Falling back on generic information extractor.
[generic] mirK3SbmFLNNC41tc5sXMf: Downloading webpage
[proxychains] Random chain  ...  127.0.0.1:9050  ...  dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:80  ...  OK
[generic] mirK3SbmFLNNC41tc5sXMf: Extracting information
[debug] Looking for video embeds
[download] Downloading playlist: Off-Grid Water Pumping Solutions - LIVE CONSULTATION [ LISTEN IN ]
[generic] playlist Off-Grid Water Pumping Solutions - LIVE CONSULTATION [ LISTEN IN ]: Downloading 1 videos
[download] Downloading video 1 of 1
[debug] [PeerTube] Extracting URL: peertube:dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:mirK3SbmFLNNC41tc5sXMf
[PeerTube] mirK3SbmFLNNC41tc5sXMf: Downloading video JSON
[proxychains] Random chain  ...  127.0.0.1:9050  ...  dollarvifyat7aehsklwzl2vf4rpkn5t4bftecepzfmv4q4fq53rxwyd.onion:443 <--socket error or timeout!
ERROR: [PeerTube] mirK3SbmFLNNC41tc5sXMf: Unable to download webpage: <urlopen error [Errno 111] Connection refused> (caused by URLError(ConnectionRefusedError(111, 'Connection refused')))
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 639, in extract
    ie_result = self._real_extract(url)
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/peertube.py", line 1205, in _real_extract
    video = self._call_api(
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/peertube.py", line 1176, in _call_api
    return self._download_json(
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 1027, in _download_json
    res = self._download_json_handle(
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 1006, in _download_json_handle
    res = self._download_webpage_handle(
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 798, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query, expected_status=expected_status)
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 783, in _request_webpage
    raise ExtractorError(errmsg, cause=err)

  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3.10/http/client.py", line 1447, in connect
    super().connect()
  File "/usr/lib/python3.10/http/client.py", line 941, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.10/socket.py", line 845, in create_connection
    raise err
  File "/usr/lib/python3.10/socket.py", line 833, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 765, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 3606, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/site-packages/yt_dlp/utils.py", line 1539, in https_open
    return self.do_open(functools.partial(
  File "/usr/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

[download] Finished downloading playlist: Off-Grid Water Pumping Solutions - LIVE CONSULTATION [ LISTEN IN ]
```