Repository: yt-dlp/yt-dlp

Issue:
Identify onion services with their respective (already yt-dlp supported) websites
### Checklist

- [X] I'm reporting a new site support request
- [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 none of provided URLs [violate any copyrights](https://github.com/ytdl-org/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [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)
- [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 am willing to share it if required

### Region

Tor Network

### Example URLs

- [ ] Twitter has an onion service: https://twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/TwitterBlue/status/1484226494708662273 (source: https://en.wikipedia.org/wiki/Twitter#External_links )
- [x] Facebook has an onion service: https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/ (source: https://en.wikipedia.org/wiki/Facebook_onion_address )
- [ ] BBC: https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/


### Description

Identify onion services with their respective (already yt-dlp supported) websites (for example twitter is already supported by yt-dlp but its onion service is dealt with by the fallback generic extractor instead of the twitter specific one)

### Verbose log

```shell
Example for the Twitter onion service:


emily@emily:~/Videos$ yt-dlp https://twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/TwitterBlue/status/1484226494708662273
[generic] 1484226494708662273: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] 1484226494708662273: Downloading webpage
[generic] 1484226494708662273: Extracting information
ERROR: Unsupported URL: https://twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/TwitterBlue/status/1484226494708662273
```
```



Discussion:
Related: https://github.com/ytdl-org/youtube-dl/issues/30736

Especially right now, this is a very significant issue.

There are two aspects here:
1. the extractor needs to recognise the onion URL pattern;
2. as I understand, it needs to use the same base domain when accessing resources from the service, such as APIs, or the extraction will potentially be subject to the same blocking or interception that the user is trying to avoid by using the Tor site.

As far as the listed sites are concerned, the Facebook yt-dlp and yt-dl extractors address point 1 but not point 2. For both yt-dlp and yt-dl, neither Twitter nor BBC Tor sites are handled at all, and although the YouTube extractors know about some Invidious Tor sites point 2 is not addressed.

Depending on how each extractor is structured, it may be possible to patch in support for the Tor site, or it may be easier to make a new or subclass extractor class (or classes).

Resolving patch:
diff --git a/yt_dlp/extractor/bbc.py b/yt_dlp/extractor/bbc.py
--- a/yt_dlp/extractor/bbc.py
+++ b/yt_dlp/extractor/bbc.py
@@ -591,7 +591,12 @@ def _real_extract(self, url):
 class BBCIE(BBCCoUkIE):
     IE_NAME = 'bbc'
     IE_DESC = 'BBC'
-    _VALID_URL = r'https?://(?:www\.)?bbc\.(?:com|co\.uk)/(?:[^/]+/)+(?P<id>[^/#?]+)'
+    _VALID_URL = r'''(?x)
+        https?://(?:www\.)?(?:
+            bbc\.(?:com|co\.uk)|
+            bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd\.onion|
+            bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad\.onion
+        )/(?:[^/]+/)+(?P<id>[^/#?]+)'''
 
     _MEDIA_SETS = [
         'pc',
@@ -841,6 +846,12 @@ class BBCIE(BBCCoUkIE):
             'upload_date': '20190604',
             'categories': ['Psychology'],
         },
+    }, {  # onion routes
+        'url': 'https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/news/av/world-europe-63208576',
+        'only_matching': True,
+    }, {
+        'url': 'https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/sport/av/football/63195681',
+        'only_matching': True,
     }]
 
     @classmethod


Test patch: