Repository: yt-dlp/yt-dlp
Issue category: Bug Report

Issue:
[twitter:spaces] yt-dlp errors with "Twitter Spaces require authentication" when that doesn't seem to be the case.
### 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)
- [ ] 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

any

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

yt-dlp reports that Twitter's "spaces" require authentication but it appears they do not. I am not sure if that's a change that was made on Twitter's side recently, but I am able to get the m3u8 manually from the browser (without login) and also to get the extraction to work by removing the login check on lines 1859-1860 in the `yt_dlp/extractor/twitter.py` file (however, that invokes ffmpeg instead of the usual yt-dlp interface so I'm not sure if that's a permanent PR-worthy fix, so I'm only posting it as an issue for now).

### 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: ['https://twitter.com/i/spaces/1dRKZdXXOeQJB', '-v', '--update']
[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.10.07 from yt-dlp/yt-dlp [1a176d874] (zip)
[debug] Python 3.12.7 (CPython x86_64 64bit) - Linux-6.11.3-arch1-1-x86_64-with-glibc2.40 (OpenSSL 3.3.2 3 Sep 2024, glibc 2.40)
[debug] exe versions: ffmpeg 7.0.2 (setts), ffprobe 7.0.2
[debug] Optional libraries: pycrypto-3.21.0, sqlite3-3.46.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1838 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.10.07 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.10.07 from yt-dlp/yt-dlp)
[twitter:spaces] Extracting URL: https://twitter.com/i/spaces/1dRKZdXXOeQJB
ERROR: [twitter:spaces] 1dRKZdXXOeQJB: Twitter Spaces require authentication. Use --cookies, --cookies-from-browser, --username and --password, --netrc-cmd, or --netrc (twitter) to provide account credentials
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 741, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/twitter.py", line 1860, in _real_extract
    self.raise_login_required('Twitter Spaces require authentication')
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1257, in raise_login_required
    raise ExtractorError(msg, expected=True)
```



Hints:
> I am not sure if that's a change that was made on Twitter's side recently

Not sure if it was recently, but it was definitely a change made on Twitter's end in the time since the auth check was added

> however, that invokes ffmpeg instead of the usual yt-dlp interface so I'm not sure if that's a permanent PR-worthy fix, so I'm only posting it as an issue for now

This is intentional, ffmpeg is needed as the downloader in order for the result to be a playable file in some cases
That's good - should I submit a PR for it then? I am not very proficient with python but it seems like removing the check wouldn't break anything else.
> should I submit a PR for it then?

sure

Patch:
diff --git a/yt_dlp/extractor/twitter.py b/yt_dlp/extractor/twitter.py
index aca94df2dd92..5adaf16393c5 100644
--- a/yt_dlp/extractor/twitter.py
+++ b/yt_dlp/extractor/twitter.py
@@ -934,14 +934,13 @@ class TwitterIE(TwitterBaseIE):
             'uploader_id': 'MoniqueCamarra',
             'live_status': 'was_live',
             'release_timestamp': 1658417414,
-            'description': 'md5:acce559345fd49f129c20dbcda3f1201',
+            'description': r're:Twitter Space participated by Sergej Sumlenny.+',
             'timestamp': 1658407771,
             'release_date': '20220721',
             'upload_date': '20220721',
         },
         'add_ie': ['TwitterSpaces'],
         'params': {'skip_download': 'm3u8'},
-        'skip': 'Requires authentication',
     }, {
         # URL specifies video number but --yes-playlist
         'url': 'https://twitter.com/CTVJLaidlaw/status/1600649710662213632/video/1',
@@ -1856,8 +1855,6 @@ def _build_graphql_query(self, space_id):
 
     def _real_extract(self, url):
         space_id = self._match_id(url)
-        if not self.is_logged_in:
-            self.raise_login_required('Twitter Spaces require authentication')
         space_data = self._call_graphql_api('HPEisOmj1epUNLCWTYhUWw/AudioSpaceById', space_id)['audioSpace']
         if not space_data:
             raise ExtractorError('Twitter Space not found', expected=True)


Test patch: