mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api/twitter: proxy thumbnails
This commit is contained in:
parent
07dc176024
commit
1064be6a7a
1 changed files with 10 additions and 1 deletions
|
@ -180,12 +180,21 @@ export default async function({ id, index, toGif, dispatcher }) {
|
||||||
isGif: media[0].type === "animated_gif"
|
isGif: media[0].type === "animated_gif"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
const proxyThumb = (url) =>
|
||||||
|
createStream({
|
||||||
|
service: "twitter",
|
||||||
|
type: "default",
|
||||||
|
u: url,
|
||||||
|
filename: `image.${new URL(url).pathname.split(".", 2)[1]}`
|
||||||
|
})
|
||||||
|
|
||||||
const picker = media.map((content, i) => {
|
const picker = media.map((content, i) => {
|
||||||
if (content.type === "photo") {
|
if (content.type === "photo") {
|
||||||
let url = `${content.media_url_https}?name=4096x4096`;
|
let url = `${content.media_url_https}?name=4096x4096`;
|
||||||
return {
|
return {
|
||||||
type: "photo",
|
type: "photo",
|
||||||
url,
|
url,
|
||||||
|
thumb: proxyThumb(url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +216,7 @@ export default async function({ id, index, toGif, dispatcher }) {
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
url,
|
url,
|
||||||
thumb: content.media_url_https
|
thumb: proxyThumb(content.media_url_https),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { picker };
|
return { picker };
|
||||||
|
|
Loading…
Reference in a new issue