mirror of
https://github.com/venera-app/venera-configs.git
synced 2025-09-27 00:27:23 +00:00
[hitomi.la] bugfix (#152)
* [hitomi.la]Fix issue that galleries without language tag cannot be loaded * [hitomi.la] fix title error on loading by category * [hitomi.la] Fixed a bug where results could conflict when multiple searches occur simultaneously. * [hitomi.la] Update to version 1.1.2
This commit is contained in:
128
hitomi.js
128
hitomi.js
@@ -995,7 +995,7 @@ class Hitomi extends ComicSource {
|
||||
// unique id of the source
|
||||
key = "hitomi";
|
||||
|
||||
version = "1.1.1";
|
||||
version = "1.1.2";
|
||||
|
||||
minAppVersion = "1.4.6";
|
||||
|
||||
@@ -1004,7 +1004,7 @@ class Hitomi extends ComicSource {
|
||||
|
||||
galleryCache = [];
|
||||
categoryResultCache = undefined;
|
||||
searchResultCache = undefined;
|
||||
searchResultCaches = new Map();
|
||||
|
||||
_mapGalleryBlockInfoToComic(n) {
|
||||
return new Comic({
|
||||
@@ -1088,95 +1088,24 @@ class Hitomi extends ComicSource {
|
||||
title: "hitomi.la",
|
||||
parts: [
|
||||
{
|
||||
name: "Language",
|
||||
name: "语言",
|
||||
type: "fixed",
|
||||
categories: [
|
||||
{
|
||||
label: "Chinese",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "language",
|
||||
param: "chinese",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "English",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "language",
|
||||
param: "english",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
categories: ["汉语", "英语"],
|
||||
itemType: "category",
|
||||
categoryParams: ["language:chinese", "language:english"],
|
||||
},
|
||||
{
|
||||
name: "类别",
|
||||
type: "fixed",
|
||||
categories: [
|
||||
{
|
||||
label: "doujinshi",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "doujinshi",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "manga",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "manga",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "artistcg",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "artistcg",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "gamecg",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "gamecg",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "imageset",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "imageset",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "anime",
|
||||
target: {
|
||||
page: "category",
|
||||
attributes: {
|
||||
category: "type",
|
||||
param: "anime",
|
||||
},
|
||||
},
|
||||
},
|
||||
categories: ["同人志", "漫画", "画师CG", "游戏CG", "图集", "动画"],
|
||||
itemType: "category",
|
||||
categoryParams: [
|
||||
"type:doujinshi",
|
||||
"type:manga",
|
||||
"type:artistcg",
|
||||
"type:gamecg",
|
||||
"type:imageset",
|
||||
"type:anime",
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -1195,9 +1124,11 @@ class Hitomi extends ComicSource {
|
||||
* @returns {Promise<{comics: Comic[], maxPage: number}>}
|
||||
*/
|
||||
load: async (category, param, options, page) => {
|
||||
const term = param;
|
||||
if (!term.includes(":"))
|
||||
throw new Error("不合法的标签,请使用namespace:tag的格式");
|
||||
if (page === 1) {
|
||||
const option = parseInt(options[0]);
|
||||
const term = category + ":" + param;
|
||||
const searchOptions = {
|
||||
term,
|
||||
orderby: "date",
|
||||
@@ -1351,6 +1282,7 @@ class Hitomi extends ComicSource {
|
||||
* @returns {Promise<{comics: Comic[], maxPage: number}>}
|
||||
*/
|
||||
load: async (keyword, options, page) => {
|
||||
const cacheKey = (keyword || "") + "|" + options.join(",");
|
||||
if (page === 1) {
|
||||
const option = parseInt(options[0]);
|
||||
const term = keyword;
|
||||
@@ -1392,11 +1324,11 @@ class Hitomi extends ComicSource {
|
||||
const comics = (await get_galleryblocks(result.gids)).map((n) =>
|
||||
this._mapGalleryBlockInfoToComic(n)
|
||||
);
|
||||
this.searchResultCache = {
|
||||
this.searchResultCaches.set(cacheKey, {
|
||||
type: "single",
|
||||
state: result.state,
|
||||
count: result.count,
|
||||
};
|
||||
});
|
||||
return {
|
||||
comics,
|
||||
maxPage: Math.ceil(result.count / 25),
|
||||
@@ -1407,20 +1339,21 @@ class Hitomi extends ComicSource {
|
||||
result.gids.slice(25 * page - 25, 25 * page)
|
||||
)
|
||||
).map((n) => this._mapGalleryBlockInfoToComic(n));
|
||||
this.searchResultCache = {
|
||||
this.searchResultCaches.set(cacheKey, {
|
||||
type: "all",
|
||||
gids: result.gids,
|
||||
count: result.count,
|
||||
};
|
||||
});
|
||||
return {
|
||||
comics,
|
||||
maxPage: Math.ceil(result.count / 25),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if (this.searchResultCache.type === "single") {
|
||||
const searchResultCache = this.searchResultCaches.get(cacheKey);
|
||||
if (searchResultCache.type === "single") {
|
||||
const result = await getSingleTagSearchPage({
|
||||
state: this.searchResultCache.state,
|
||||
state: searchResultCache.state,
|
||||
page: page - 1,
|
||||
});
|
||||
const comics = (await get_galleryblocks(result.galleryids)).map((n) =>
|
||||
@@ -1428,17 +1361,17 @@ class Hitomi extends ComicSource {
|
||||
);
|
||||
return {
|
||||
comics,
|
||||
maxPage: Math.ceil(this.searchResultCache.count / 25),
|
||||
maxPage: Math.ceil(searchResultCache.count / 25),
|
||||
};
|
||||
} else {
|
||||
const comics = (
|
||||
await get_galleryblocks(
|
||||
this.searchResultCache.gids.slice(25 * page - 25, 25 * page)
|
||||
searchResultCache.gids.slice(25 * page - 25, 25 * page)
|
||||
)
|
||||
).map((n) => this._mapGalleryBlockInfoToComic(n));
|
||||
return {
|
||||
comics,
|
||||
maxPage: Math.ceil(this.searchResultCache.count / 25),
|
||||
maxPage: Math.ceil(searchResultCache.count / 25),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1526,7 +1459,8 @@ class Hitomi extends ComicSource {
|
||||
if ("type" in data && data.type) tags.set("type", [data.type]);
|
||||
if (data.groups.length) tags.set("groups", data.groups);
|
||||
if (data.artists.length) tags.set("artists", data.artists);
|
||||
if ("language" in data && data.language) tags.set("language", [data.language]);
|
||||
if ("language" in data && data.language)
|
||||
tags.set("language", [data.language]);
|
||||
if (data.series.length) tags.set("series", data.series);
|
||||
if (data.characters.length) tags.set("characters", data.characters);
|
||||
if (data.females.length) tags.set("females", data.females);
|
||||
|
@@ -72,7 +72,7 @@
|
||||
"name": "hitomi.la",
|
||||
"fileName": "hitomi.js",
|
||||
"key": "hitomi",
|
||||
"version": "1.1.1"
|
||||
"version": "1.1.2"
|
||||
},
|
||||
{
|
||||
"name": "comick",
|
||||
|
Reference in New Issue
Block a user