diff --git a/databases/_upgrade_sponsorTimes_25.sql b/databases/_upgrade_sponsorTimes_25.sql new file mode 100644 index 0000000..e40d1ed --- /dev/null +++ b/databases/_upgrade_sponsorTimes_25.sql @@ -0,0 +1,13 @@ +BEGIN TRANSACTION; + +CREATE TABLE IF NOT EXISTS "videoInfo" ( + "videoID" TEXT PRIMARY KEY NOT NULL, + "channelID" TEXT NOT NULL, + "title" TEXT NOT NULL, + "published" REAL NOT NULL, + "genreUrl" REAL NOT NULL +); + +UPDATE "config" SET value = 25 WHERE key = 'version'; + +COMMIT; \ No newline at end of file diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index 9934e53..54e2cfb 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -651,6 +651,11 @@ export async function postSkipSegments(req: Request, res: Response): Promise { const queryDatabase = (videoID: string) => db.prepare("get", `SELECT "startTime", "endTime", "locked", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); const queryDatabaseActionType = (videoID: string) => db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "actionType" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); const queryDatabaseDuration = (videoID: string) => db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "videoDuration" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID]); + const queryDatabaseVideoInfo = (videoID: string) => db.prepare("get", `SELECT * FROM "videoInfo" WHERE "videoID" = ?`, [videoID]); const endpoint = "/api/skipSegments"; const postSkipSegmentJSON = (data: Record) => client({ @@ -107,6 +108,17 @@ describe("postSkipSegments", () => { category: "sponsor", }; assert.ok(partialDeepEquals(row, expected)); + + const videoInfo = await queryDatabaseVideoInfo(videoID); + const expectedVideoInfo = { + videoID, + title: "Example Title", + channelID: "ExampleChannel", + published: 123, + genreUrl: "" + }; + assert.ok(partialDeepEquals(videoInfo, expectedVideoInfo)); + done(); }) .catch(err => done(err)); diff --git a/test/youtubeMock.ts b/test/youtubeMock.ts index 39d8c8f..44d271a 100644 --- a/test/youtubeMock.ts +++ b/test/youtubeMock.ts @@ -35,6 +35,8 @@ export class YouTubeApiMock { err: null, data: { title: "Example Title", + authorId: "ExampleChannel", + published: 123, lengthSeconds: 4980, videoThumbnails: [ {