Add meiliserach server support

Fix GalleryMetadata contains escaped html data
This commit is contained in:
2023-06-14 11:07:25 +08:00
parent d78276fc62
commit 0a6dc6ad2b
14 changed files with 450 additions and 29 deletions

View File

@@ -1,3 +1,4 @@
import { unescape } from "std/html/mod.ts";
import { GMeta } from "../db.ts";
export type GalleryMetadataTorrentInfo = {
@@ -12,10 +13,13 @@ export type GalleryMetadataSingle = {
gid: number;
token: string;
archiver_key: string;
/// HTML escaped
title: string;
/// HTML escaped
title_jpn: string;
category: string;
thumb: string;
/// HTML escaped
uploader: string;
posted: string;
filecount: string;
@@ -45,10 +49,10 @@ class GalleryMetadata {
return {
gid: g.gid,
token: g.token,
title: g.title,
title_jpn: g.title_jpn,
title: unescape(g.title),
title_jpn: unescape(g.title_jpn),
category: g.category,
uploader: g.uploader,
uploader: unescape(g.uploader),
posted: parseInt(g.posted),
filecount: parseInt(g.filecount),
filesize: g.filesize,

View File

@@ -1,3 +1,4 @@
import { assert, assertEquals } from "std/testing/asserts.ts";
import { Client } from "../client.ts";
import { load_settings } from "../config.ts";
import { API_PERMISSION } from "../test_base.ts";
@@ -8,6 +9,17 @@ Deno.test({
}, async () => {
const cfg = await load_settings("./config.json");
const client = new Client(cfg);
const re = await client.fetchGalleryMetadataByAPI([2552611, "3132307627"]);
const re = await client.fetchGalleryMetadataByAPI([1389215, "b5e43bd12d"]);
console.log(re.obj);
const gdata = re.map.get(1389215);
assert(gdata !== undefined && typeof gdata !== "string");
assertEquals(
gdata.title,
"(C95) [Shiratamaco (Shiratama)] Usagi Syndrome 4 (Gochuumon wa Usagi desu ka?) [Chinese] [白玉症候群&绅士仓库联合汉化]",
);
const gmeta = re.convert(gdata);
assertEquals(
gmeta.title,
"(C95) [Shiratamaco (Shiratama)] Usagi Syndrome 4 (Gochuumon wa Usagi desu ka?) [Chinese] [白玉症候群&绅士仓库联合汉化]",
);
});