mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-12-22 13:07:00 +00:00
Proxy thumbnails in cloudtube
This commit is contained in:
parent
ca8d26c722
commit
b0b00014d5
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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user