1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-22 15:47:30 +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
}
})
}
}
]

View File

@ -1,8 +1,7 @@
mixin video_list_item(video, instanceOrigin)
- if (!instanceOrigin) instanceOrigin = "https://i.ytimg.com"
- let link = `/watch?v=${video.videoId}`
a(href=link tabindex="-1").thumbnail
img(src=`${instanceOrigin}/vi/${video.videoId}/mqdefault.jpg` width=320 height=180 alt="").image
img(src=`/vi/${video.videoId}/mqdefault.jpg` width=320 height=180 alt="").image
if video.second__lengthText != undefined
span.duration= video.second__lengthText
.info