[twitter] extract 'type' metadata (#6111)

This commit is contained in:
Mike Fährmann
2024-08-31 12:47:44 +02:00
parent 8eaae29bf9
commit ef8b1bc56e
2 changed files with 9 additions and 0 deletions

View File

@@ -155,6 +155,7 @@ class TwitterExtractor(Extractor):
if not self.unavailable:
continue
mtype = media.get("type")
descr = media.get("ext_alt_text")
width = media["original_info"].get("width", 0)
height = media["original_info"].get("height", 0)
@@ -164,6 +165,7 @@ class TwitterExtractor(Extractor):
files.append({
"url": "ytdl:{}/i/web/status/{}".format(
self.root, tweet["id_str"]),
"type" : mtype,
"width" : width,
"height" : height,
"extension" : None,
@@ -177,6 +179,7 @@ class TwitterExtractor(Extractor):
)
files.append({
"url" : variant["url"],
"type" : mtype,
"width" : width,
"height" : height,
"bitrate" : variant.get("bitrate", 0),
@@ -193,6 +196,7 @@ class TwitterExtractor(Extractor):
base = url.rpartition("=")[0] + "="
files.append(text.nameext_from_url(url, {
"url" : base + self._size_image,
"type" : mtype,
"width" : width,
"height" : height,
"_fallback" : self._image_fallback(base),

View File

@@ -319,6 +319,8 @@ __tests__ = (
"#category": ("", "twitter", "tweet"),
"#class" : twitter.TwitterTweetExtractor,
"#sha1_url": "3a2a43dc5fb79dd5432c701d8e55e87c4e551f47",
"type": "photo",
},
{
@@ -327,6 +329,8 @@ __tests__ = (
"#category": ("", "twitter", "tweet"),
"#class" : twitter.TwitterTweetExtractor,
"#pattern" : r"https://video.twimg.com/ext_tw_video/.+\.mp4\?tag=5",
"type": "video",
},
{
@@ -587,6 +591,7 @@ Youll be able to receive four Galarian form Pokémon with Hidden Abilities, p
"#class" : twitter.TwitterTweetExtractor,
"description": "oc",
"type" : "photo",
},
{