Add /api/filemeta and /api/filemeta/[token]

This commit is contained in:
2023-06-22 20:26:44 +08:00
parent ee1daa103e
commit 03b65d71c2
6 changed files with 121 additions and 10 deletions

13
db.ts
View File

@@ -461,6 +461,12 @@ export class EhDb {
return s[s.length - 1];
}
}
add_filemeta(m: EhFileMeta) {
this.db.query(
"INSERT OR REPLACE INTO filemeta VALUES (:token, :is_nsfw, :is_ad);",
m,
);
}
add_pmeta(pmeta: PMeta) {
this.db.queryEntries(
"INSERT OR REPLACE INTO pmeta VALUES (:gid, :index, :token, :name, :width, :height)",
@@ -682,6 +688,13 @@ export class EhDb {
));
return d.length ? d[0] : null;
}
get_filemeta(token: string) {
const d = this.convert_filemeta(this.db.queryEntries<EhFileMetaRaw>(
"SELECT * FROM filemeta WHERE token = ?;",
[token],
));
return d.length ? d[0] : null;
}
get_files(token: string) {
return this.convert_file(this.db.queryEntries<EhFileRaw>(
"SELECT * FROM file WHERE token = ?;",