mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Save more info in unlisted video endpoint
This commit is contained in:
parent
15b3cb20b3
commit
c5245cb8e2
2 changed files with 19 additions and 1 deletions
15
databases/_upgrade_sponsorTimes_16.sql
Normal file
15
databases/_upgrade_sponsorTimes_16.sql
Normal file
|
@ -0,0 +1,15 @@
|
|||
BEGIN TRANSACTION;
|
||||
|
||||
DROP TABLE "unlistedVideos";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "unlistedVideos" (
|
||||
"videoID" TEXT NOT NULL,
|
||||
"year" TEXT NOT NULL,
|
||||
"views" TEXT NOT NULL,
|
||||
"channelID" TEXT NOT NULL,
|
||||
"timeSubmitted" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
UPDATE "config" SET value = 16 WHERE key = 'version';
|
||||
|
||||
COMMIT;
|
|
@ -12,6 +12,9 @@ import { Logger } from '../utils/logger';
|
|||
|
||||
export function addUnlistedVideo(req: Request, res: Response) {
|
||||
const videoID = req.body.videoID;
|
||||
const year = req.body.year || 0;
|
||||
const views = req.body.views || 0;
|
||||
const channelID = req.body.channelID || "Unknown";
|
||||
|
||||
if (videoID === undefined || typeof(videoID) !== "string" || videoID.length !== 11) {
|
||||
res.status(400).send("Invalid parameters");
|
||||
|
@ -20,7 +23,7 @@ export function addUnlistedVideo(req: Request, res: Response) {
|
|||
|
||||
try {
|
||||
const timeSubmitted = Date.now();
|
||||
db.prepare('run', `INSERT INTO "unlistedVideos" ("videoID", "timeSubmitted") values (?, ?)`, [videoID, timeSubmitted]);
|
||||
db.prepare('run', `INSERT INTO "unlistedVideos" ("videoID", "year", "views", "channelID", "timeSubmitted") values (?, ?, ?, ?, ?)`, [videoID, year, views, channelID, timeSubmitted]);
|
||||
} catch (err) {
|
||||
Logger.error(err);
|
||||
res.sendStatus(500);
|
||||
|
|
Loading…
Reference in a new issue