From 00da2a93392502be954224140ed3c236eb8a9be6 Mon Sep 17 00:00:00 2001 From: wukko Date: Sat, 31 Aug 2024 14:19:01 +0600 Subject: [PATCH] api/twitter: return a filename for images --- api/src/processing/services/twitter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/processing/services/twitter.js b/api/src/processing/services/twitter.js index d45ff713..7ed7fe4d 100644 --- a/api/src/processing/services/twitter.js +++ b/api/src/processing/services/twitter.js @@ -157,6 +157,8 @@ export default async function({ id, index, toGif, dispatcher }) { media = [media[index]] } + const getFileExt = (url) => new URL(url).pathname.split(".", 2)[1]; + switch (media?.length) { case undefined: case 0: @@ -168,6 +170,7 @@ export default async function({ id, index, toGif, dispatcher }) { return { type: "proxy", isPhoto: true, + filename: `twitter_${id}.${getFileExt(media[0].media_url_https)}`, urls: `${media[0].media_url_https}?name=4096x4096` } } @@ -185,7 +188,7 @@ export default async function({ id, index, toGif, dispatcher }) { service: "twitter", type: "proxy", u: url, - filename: `twitter_${id}_${i + 1}.${new URL(url).pathname.split(".", 2)[1]}` + filename: `twitter_${id}_${i + 1}.${getFileExt(url)}` }) const picker = media.map((content, i) => {