pow captcha & search
This commit is contained in:
parent
e965682e33
commit
8a4602fbfd
|
@ -1,11 +1,21 @@
|
||||||
const validate = require('../utils/validate.js')
|
const validate = require('../utils/validate.js')
|
||||||
|
const { PrismaClient } = require('@prisma/client')
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
|
||||||
exports.searchVideo = async (req, res) => {
|
exports.searchVideo = async (req, res) => {
|
||||||
const id = await validate.validateVideoInput(req.query.url)
|
const id = await validate.validateVideoInput(req.query.search)
|
||||||
if (id.fail) {
|
if (id.fail) {
|
||||||
res.status(500).send(id.message)
|
const videos = await prisma.videos.findMany({
|
||||||
|
where: {
|
||||||
|
title: {
|
||||||
|
contains: req.query.search,
|
||||||
|
mode: 'insensitive'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
res.json(videos)
|
||||||
} else {
|
} else {
|
||||||
res.send(`<script>window.location.href = '${process.env.FRONTEND}/watch?v=${id}'</script>`)
|
res.send(`redirect-${process.env.FRONTEND}/watch?v=${id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ exports.save = async (ws, req) => {
|
||||||
|
|
||||||
if (already) return ws.send(`DONE - ${process.env.FRONTEND}/watch?v=${id}`)
|
if (already) return ws.send(`DONE - ${process.env.FRONTEND}/watch?v=${id}`)
|
||||||
|
|
||||||
ws.send('CAPTCHA - Please complete the captcha:')
|
ws.send('DATA - This process is automatic. Your video will start archiving shortly.')
|
||||||
|
ws.send('CAPTCHA - Solving a cryptographic challenge before downloading.')
|
||||||
|
|
||||||
ws.on('message', async function(msg) {
|
ws.on('message', async function(msg) {
|
||||||
if (msg == 'alive') return
|
if (msg == 'alive') return
|
||||||
|
@ -107,7 +108,8 @@ exports.playlist = async (ws, req) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let status = 'captcha'
|
let status = 'captcha'
|
||||||
ws.send('CAPTCHA - Please complete the captcha:')
|
ws.send('DATA - This process is automatic. Your video will start archiving shortly.')
|
||||||
|
ws.send('CAPTCHA - Solving a cryptographic challenge before downloading.')
|
||||||
|
|
||||||
ws.on('message', async function(msg) {
|
ws.on('message', async function(msg) {
|
||||||
if (msg == 'alive') return
|
if (msg == 'alive') return
|
||||||
|
@ -213,7 +215,8 @@ exports.channel = async (ws, req) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let status = 'captcha'
|
let status = 'captcha'
|
||||||
ws.send('CAPTCHA - Please complete the captcha:')
|
ws.send('DATA - This process is automatic. Your video will start archiving shortly.')
|
||||||
|
ws.send('CAPTCHA - Solving a cryptographic challenge before downloading.')
|
||||||
|
|
||||||
ws.on('message', async function(msg) {
|
ws.on('message', async function(msg) {
|
||||||
if (msg == 'alive') return
|
if (msg == 'alive') return
|
||||||
|
|
|
@ -25,6 +25,8 @@ model videos {
|
||||||
channelAvatar String
|
channelAvatar String
|
||||||
playlist String?
|
playlist String?
|
||||||
disabled Boolean @default(false)
|
disabled Boolean @default(false)
|
||||||
|
|
||||||
|
@@index([title], name: "idx_title")
|
||||||
}
|
}
|
||||||
|
|
||||||
model reports {
|
model reports {
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
const fetch = require('node-fetch')
|
const fetch = require('node-fetch')
|
||||||
|
|
||||||
async function checkCaptcha(response) {
|
async function checkCaptcha(response) {
|
||||||
const confirm = await (await fetch('https://hcaptcha.com/siteverify', {
|
const confirm = await (await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: new URLSearchParams({
|
body: JSON.stringify({
|
||||||
'response': response,
|
'response': response,
|
||||||
'secret': process.env.CAPTCHA_SECRET
|
'secret': process.env.CAPTCHA_SECRET
|
||||||
})
|
}),
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/json'
|
||||||
|
}
|
||||||
})).json()
|
})).json()
|
||||||
|
|
||||||
return confirm.success
|
return confirm.success
|
||||||
|
|
Loading…
Reference in New Issue