[tenor] extract more metadata
- format - id_format - size - duration
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user