fix: unhandled timezone mismatch when inserting to database

This commit is contained in:
alikia2x (寒寒) 2025-03-16 14:23:11 +08:00
parent 0ff1c78dcc
commit a9ac8de547
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -4,6 +4,7 @@ import { formatTimestampToPsql } from "lib/utils/formatTimestampToPostgre.ts";
import logger from "lib/log/logger.ts";
import { ClassifyVideoQueue } from "lib/mq/index.ts";
import { userExistsInBiliUsers, videoExistsInAllData } from "lib/db/allData.ts";
import { HOUR, SECOND } from "$std/datetime/constants.ts";
export async function insertVideoInfo(client: Client, aid: number) {
const videoExists = await videoExistsInAllData(client, aid);
@ -21,7 +22,7 @@ export async function insertVideoInfo(client: Client, aid: number) {
.filter((tag) => tag.tag_type in ["old_channel", "topic"])
.map((tag) => tag.tag_name).join(",");
const title = data.View.title;
const published_at = formatTimestampToPsql(data.View.pubdate * 1000);
const published_at = formatTimestampToPsql(data.View.pubdate * SECOND + 8 * HOUR);
const duration = data.View.duration;
await client.queryObject(
`INSERT INTO bilibili_metadata (aid, bvid, description, uid, tags, title, published_at, duration)