[tenor] extract more metadata

- format
- id_format
- size
- duration
This commit is contained in:
Mike Fährmann
2025-06-26 10:42:48 +02:00
parent 718ed6a1e7
commit ebaf789ac7
2 changed files with 19 additions and 1 deletions

View File

@@ -40,7 +40,11 @@ class TenorExtractor(Extractor):
continue
url = fmt["url"]
gif["id_format"] = url.rsplit("/", 2)[1]
gif["format"] = fmt["name"]
gif["width"], gif["height"] = fmt["dims"]
gif["duration"] = fmt["duration"]
gif["size"] = fmt["size"]
gif["title"] = gif["h1_title"][:-4]
gif["description"] = gif.pop("content_description", "")
gif["date"] = text.parse_timestamp(gif["created"])
@@ -52,7 +56,9 @@ class TenorExtractor(Extractor):
media_formats = gif["media_formats"]
for fmt in self.formats:
if fmt in media_formats:
return media_formats[fmt]
media = media_formats[fmt]
media["name"] = fmt
return media
def _search_results(self, query):
url = "https://tenor.googleapis.com/v2/search"

View File

@@ -22,9 +22,13 @@ __tests__ = (
"filename" : "moving",
"h1_title" : "Moving Sticker",
"hasaudio" : False,
"format" : "gif",
"width" : 467,
"height" : 498,
"size" : 60157,
"duration" : 0,
"id" : "8525772382434057283",
"id_format": "dlGgz3LRXEMAAAAC",
"index" : 0,
"itemurl" : "https://tenor.com/view/moving-gif-8525772382434057283",
"long_title": "Moving Sticker - Moving Stickers",
@@ -66,6 +70,14 @@ __tests__ = (
"#class" : tenor.TenorImageExtractor,
"#options": {"format": ["mkv", "foobar", "webp"]},
"#results": "https://media.tenor.com/dlGgz3LRXEMAAAAx/moving.webp",
"format" : "webp",
"width" : 468,
"height" : 498,
"size" : 9808,
"duration" : 0,
"id" : "8525772382434057283",
"id_format": "dlGgz3LRXEMAAAAx",
},
{