Update anime/hianime/source.js
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
class HiAnime {
|
||||
constructor() {
|
||||
this.type = "anime-streaming";
|
||||
this.version = "1.0.7";
|
||||
this.version = "1.0.8";
|
||||
this.baseUrl = "https://hianime.to";
|
||||
|
||||
this._dubCache = {};
|
||||
}
|
||||
|
||||
getSettings() {
|
||||
@@ -276,6 +278,54 @@ class HiAnime {
|
||||
return out;
|
||||
}
|
||||
|
||||
_hasDubForAnimeId(animeId) {
|
||||
const id = String(animeId || "").trim();
|
||||
if (!id) return false;
|
||||
|
||||
if (typeof this._dubCache[id] === "boolean") {
|
||||
return this._dubCache[id];
|
||||
}
|
||||
|
||||
try {
|
||||
const j = this._getJson(
|
||||
`${this.baseUrl}/ajax/v2/episode/list/${encodeURIComponent(id)}`,
|
||||
this._headersJson()
|
||||
);
|
||||
|
||||
const html = this._decodeHtml(String(j.html || j.result || ""));
|
||||
if (!html) {
|
||||
this._dubCache[id] = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
const re = /data-number="([^"]+)"[^>]*data-id="([^"]+)"/i;
|
||||
const m = re.exec(html);
|
||||
const epId = m ? String(m[2] || "").trim() : "";
|
||||
if (!epId) {
|
||||
this._dubCache[id] = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
const j2 = this._getJson(
|
||||
`${this.baseUrl}/ajax/v2/episode/servers?episodeId=${encodeURIComponent(epId)}`,
|
||||
this._headersJson()
|
||||
);
|
||||
|
||||
const html2 = this._decodeHtml(String(j2.html || j2.result || ""));
|
||||
if (!html2) {
|
||||
this._dubCache[id] = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
const has = /data-type\s*=\s*"(?:dub)"/i.test(html2);
|
||||
this._dubCache[id] = !!has;
|
||||
return !!has;
|
||||
} catch (e) {
|
||||
this._dubCache[id] = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
search(a1) {
|
||||
const arg = this._parseArg(a1);
|
||||
const q = this._safeStr(arg.query || arg.q || "").trim();
|
||||
@@ -377,6 +427,18 @@ class HiAnime {
|
||||
return a.normTitle.localeCompare(b.normTitle);
|
||||
});
|
||||
|
||||
|
||||
if (subOrDub === "dub") {
|
||||
const top = filtered.slice(0, 8);
|
||||
const ok = [];
|
||||
for (let i = 0; i < top.length; i++) {
|
||||
const r = top[i];
|
||||
if (this._hasDubForAnimeId(r.id)) ok.push(r);
|
||||
}
|
||||
filtered = ok;
|
||||
if (!filtered.length) return "[]";
|
||||
}
|
||||
|
||||
const mapped = filtered.map((r) => ({
|
||||
id: `${r.id}/${subOrDub}`,
|
||||
title: this._decodeHtml(r.title || ""),
|
||||
|
||||
Reference in New Issue
Block a user