1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-02 02:31:35 +00:00

Implement takedown system

This commit is contained in:
Cadence Ember 2021-11-20 19:42:34 +13:00
parent 741a1199dd
commit b9f703086f
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
10 changed files with 111 additions and 2 deletions

10
api/takedown.js Normal file
View file

@ -0,0 +1,10 @@
const constants = require("../utils/constants")
const {render} = require("pinski/plugins")
module.exports = [
{
route: "/takedown", methods: ["GET"], code: async () => {
return render(200, "pug/takedown.pug", {constants})
}
}
]

View file

@ -108,6 +108,12 @@ module.exports = [
const settings = user.getSettingsOrDefaults()
const id = url.searchParams.get("v")
// Check if playback is allowed
const videoTakedownInfo = db.prepare("SELECT id, org, url FROM TakedownVideos WHERE id = ?").get(id)
if (videoTakedownInfo) {
return render(451, "pug/takedown-video.pug", videoTakedownInfo)
}
// Media fragment
const t = url.searchParams.get("t")
let mediaFragment = converters.tToMediaFragment(t)
@ -141,6 +147,15 @@ module.exports = [
if (!video) throw new MessageError("The instance returned null.")
if (video.error) throw new InstanceError(video.error, video.identifier)
// Check if channel playback is allowed
const channelTakedownInfo = db.prepare("SELECT ucid, org, url FROM TakedownChannels WHERE ucid = ?").get(video.authorId)
if (channelTakedownInfo) {
// automatically add the entry to the videos list, so it won't be fetched again
const args = {id, ...channelTakedownInfo}
db.prepare("INSERT INTO TakedownVideos (id, org, url) VALUES (@id, @org, @url)").run(args)
return render(451, "pug/takedown-video.pug", channelTakedownInfo)
}
// process stream list ordering
const formats = sortFormats(video, settings.quality)