From ebaf789ac76e9b32fa239e4d7f231ac733d8f0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 26 Jun 2025 10:42:48 +0200 Subject: [PATCH] [tenor] extract more metadata - format - id_format - size - duration --- gallery_dl/extractor/tenor.py | 8 +++++++- test/results/tenor.py | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/tenor.py b/gallery_dl/extractor/tenor.py index 75543571..7e1f8028 100644 --- a/gallery_dl/extractor/tenor.py +++ b/gallery_dl/extractor/tenor.py @@ -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" diff --git a/test/results/tenor.py b/test/results/tenor.py index 316ca040..c002c2a6 100644 --- a/test/results/tenor.py +++ b/test/results/tenor.py @@ -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", }, {