api/twitter: return a filename for images

This commit is contained in:
wukko 2024-08-31 14:19:01 +06:00
parent d026eb75a5
commit 00da2a9339
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -157,6 +157,8 @@ export default async function({ id, index, toGif, dispatcher }) {
media = [media[index]] media = [media[index]]
} }
const getFileExt = (url) => new URL(url).pathname.split(".", 2)[1];
switch (media?.length) { switch (media?.length) {
case undefined: case undefined:
case 0: case 0:
@ -168,6 +170,7 @@ export default async function({ id, index, toGif, dispatcher }) {
return { return {
type: "proxy", type: "proxy",
isPhoto: true, isPhoto: true,
filename: `twitter_${id}.${getFileExt(media[0].media_url_https)}`,
urls: `${media[0].media_url_https}?name=4096x4096` urls: `${media[0].media_url_https}?name=4096x4096`
} }
} }
@ -185,7 +188,7 @@ export default async function({ id, index, toGif, dispatcher }) {
service: "twitter", service: "twitter",
type: "proxy", type: "proxy",
u: url, 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) => { const picker = media.map((content, i) => {