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:
parent
ca8d26c722
commit
b0b00014d5
2 changed files with 19 additions and 2 deletions
18
api/thumbnails.js
Normal file
18
api/thumbnails.js
Normal 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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue