1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 12:27:28 +00:00
cloudtube/api/thumbnails.js
2020-11-25 13:34:08 +13:00

19 lines
443 B
JavaScript

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
}
})
}
}
]