Comments (1)
Twitter has two different concepts of embedded URLs: a "card", and a pure link. The Meta tweet is an example of a "card": it has a large image (the card) that is also clickable as a link to the content. Your other two examples are pure links.
yt-dlp's Twitter extractor prioritizes cards over pure links, since cards can also be actual embedded videos, Twitter broadcasts, Spaces, etc. It tries to extract the card from the Meta tweet, but it doesn't recognize the card "name", so it returns no formats found (i.e. extracts tweet metadata without a video or URL result).
Adding the missing card name to the extractor's code would fix the inconsistency:
diff --git a/yt_dlp/extractor/twitter.py b/yt_dlp/extractor/twitter.py
index ecc865655..cfd34eff4 100644
--- a/yt_dlp/extractor/twitter.py
+++ b/yt_dlp/extractor/twitter.py
@@ -1499,7 +1499,7 @@ def get_binding_value(k):
'url': f'https://twitter.com/i/spaces/{get_binding_value("id")}',
'ie_key': TwitterSpacesIE.ie_key(),
}
- elif card_name == 'summary':
+ elif card_name in ('summary', 'summary_large_image'):
yield {
'_type': 'url',
'url': get_binding_value('card_url'),
However, some more investigation should probably be done on other potential card names to be included in this tuple.
I do get the sense that maybe what you really want is to be able to extract tweet metadata for all tweets instead of following any of these redirects. It should be stated that yt-dlp is first and foremost an audio/video downloader, not a metadata extractor. If no video is embedded in the tweet, yt-dlp will (and should) follow the embedded URL to try to find any video at its destination. The ability to extract pure tweet metadata was added to the Twitter extractor as a bonus; it is not the focus. But if you want to be able to extract only twitter metadata from every tweet, this is possible via the yt-dlp Python API and the extract_flat
param:
import json
import yt_dlp
URL = 'https://twitter.com/YouTube/status/1780725427520065913'
ydl_opts = {
'extract_flat': True,
'ignore_no_formats_error': True,
'no_warnings': True,
'quiet': True,
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(URL, download=False)
info = ydl.sanitize_info(info)
print(json.dumps(info))
from yt-dlp.
Related Issues (20)
- BBC News fails with "Unable to extract playlist data" error HOT 5
- yt-dlp --write-subs --sub-lang "live_chat" on a Live stream is always Top Chat
- Different response to --output, in two different situations HOT 5
- 3speak broken HOT 1
- PhantomJS is unmaintained HOT 1
- X/Twitter video URLs no longer work HOT 1
- Add options to prevent download if sponsorblock entry not found HOT 1
- 6play.fr No video formats found HOT 1
- FFMPEG Convertion failed HOT 2
- yt-dlp cannot download video using its id code: no such option: -0. How i can do it? HOT 5
- Proposal: Embed JSON subtitles as file attachments HOT 3
- `ERROR: url must be a string` when using youtube `player_client=all` extractor-arg HOT 1
- yt-dlp001
- Is it possible to output the archive file of a playlist with this syntax: "%(playlist_title)s/downloaded_archive.txt" HOT 9
- --output ignored when using --split-chapters HOT 1
- `-o "%(duration>%H:%M:%S)s"` is sanitized to `01_16_58` while `-o "%(duration>%H: %M: %S)s"` is sanitized to `01: 16: 58` HOT 6
- `yt-dlp -x $URL` not working: 404 not found error HOT 16
- Error extract for downloading a profile from tiktok HOT 1
- My bad, no issue HOT 5
- Unexpected results when downloading youtube clips in post-live manifestless mode HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yt-dlp.