1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-10 02:27:29 +00:00
cloudtube/api/thumbnails.js
2021-05-11 21:58:41 +12:00

21 lines
501 B
JavaScript

/** @type {import("node-fetch").default} */
// @ts-ignore
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
}
})
}
}
]