mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-24 12:08:55 +01:00
api/twitter: return a filename for images
This commit is contained in:
parent
d026eb75a5
commit
00da2a9339
1 changed files with 4 additions and 1 deletions
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in a new issue