update: the archive script
This commit is contained in:
parent
2fc9014dfb
commit
368c049255
@ -9,6 +9,7 @@
|
||||
<file url="file://$PROJECT_DIR$/src/importSnapshots.ts" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_1.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_10.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_3.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_4.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_5.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
@ -17,6 +18,8 @@
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_8.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef/console_9.sql" value="0d2dd3d3-bd27-4e5f-b0fa-ff14fb2a6bef" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/360f07a5-22e0-4aa5-8453-7b7e913f2fc7/console.sql" value="360f07a5-22e0-4aa5-8453-7b7e913f2fc7" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/3909a3cf-ec53-4749-8a31-9f90fec87ee1/console_1.sql" value="3909a3cf-ec53-4749-8a31-9f90fec87ee1" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/3909a3cf-ec53-4749-8a31-9f90fec87ee1/console_2.sql" value="3909a3cf-ec53-4749-8a31-9f90fec87ee1" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/c73d5a8a-cf9a-4e08-bc75-84af9a6f1ba9/console.sql" value="c73d5a8a-cf9a-4e08-bc75-84af9a6f1ba9" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,5 +1,5 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
import { sql } from "@core/index";
|
||||
import { sql } from "@core/db/dbNew";
|
||||
import logger from "@core/log";
|
||||
import { getVideoDetails } from "@core/net/getVideoDetails";
|
||||
import arg from "arg";
|
||||
@ -45,16 +45,22 @@ async function addCandidates() {
|
||||
|
||||
const newAids = aids.filter((aid) => !existingAidsSet.has(aid));
|
||||
|
||||
let i = 0;
|
||||
for (const aid of newAids) {
|
||||
const stmt = sqlite.query(
|
||||
`INSERT INTO bili_info_crawl (aid, status) VALUES ($aid, 'pending');`
|
||||
);
|
||||
stmt.all({ $aid: aid });
|
||||
i++;
|
||||
logger.log(`Added ${i} to local DB.`);
|
||||
}
|
||||
logger.log(`Added ${newAids.length} to local DB.`);
|
||||
const insertStmt = sqlite.prepare(
|
||||
`INSERT INTO bili_info_crawl (aid, status) VALUES (?, 'pending') ON CONFLICT DO NOTHING;`
|
||||
);
|
||||
|
||||
const insertMany = sqlite.transaction((data) => {
|
||||
for (const aid of data) {
|
||||
insertStmt.run(aid);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
insertMany(newAids);
|
||||
logger.log(`Successfully added ${newAids.length} to local DB.`);
|
||||
} catch (err) {
|
||||
logger.error(["Failed to insert candidates:", err]);
|
||||
}
|
||||
}
|
||||
|
||||
async function insertAidsToDB() {
|
||||
|
||||
2
src/getAllAids.ts
Normal file
2
src/getAllAids.ts
Normal file
@ -0,0 +1,2 @@
|
||||
import { getLatestVideoAids } from "@crawler/net/getLatestVideoAids";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user