Update to Tenor API v2 (you'll need to get a new key)

This commit is contained in:
Essem 2022-06-23 18:44:10 -05:00
parent 9321082968
commit c3a1de0d60
No known key found for this signature in database
GPG Key ID: 7D497397CC3A2A8C
1 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false, ty
// Tenor doesn't let us access a raw GIF without going through their API,
// so we use that if there's a key in the config
if (process.env.TENOR !== "") {
const data = await fetch(`https://g.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&media_filter=minimal&limit=1&key=${process.env.TENOR}`);
const data = await fetch(`https://tenor.googleapis.com/v2/posts?ids=${image2.split("-").pop()}&media_filter=gif&limit=1&key=${process.env.TENOR}`);
if (data.status === 429) {
if (extraReturnTypes) {
payload.type = "tenorlimit";
@ -57,7 +57,7 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false, ty
}
const json = await data.json();
if (json.error) throw Error(json.error);
payload.path = json.results[0].media[0].gif.url;
payload.path = json.results[0].media_formats.gif.url;
}
} else if (giphyURLs.includes(host)) {
// Can result in an HTML page instead of a GIF