1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-02 10:41:36 +00:00

Proxy thumbnails in cloudtube

This commit is contained in:
Cadence Ember 2020-11-25 13:34:08 +13:00
parent ca8d26c722
commit b0b00014d5
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 19 additions and 2 deletions

18
api/thumbnails.js Normal file
View file

@ -0,0 +1,18 @@
const fetch = require("node-fetch")
const constants = require("../utils/constants.js")
module.exports = [
{
route: `/vi/(${constants.regex.video_id})/(\\w+\\.jpg)`, methods: ["GET"], code: ({fill}) => {
const videoID = fill[0]
const file = fill[1]
return fetch(`https://i.ytimg.com/vi/${videoID}/${file}`).then(res => {
return {
statusCode: 200,
contentType: "image/jpeg",
stream: res.body
}
})
}
}
]