fix miruro
This commit is contained in:
1 parent
7c58cec433
commit
f502283d6c
3 files changed
+26
-10
No files matched your search
+11
-4
@@ -558,6 +558,12 @@ function asNumber(value) {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? number : null;
|
||||
}
|
||||
function asArray(value) {
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
function parseIdentifier(value) {
|
||||
const id = String(value || "").trim();
|
||||
if (/^tt\d+$/i.test(id)) {
|
||||
@@ -571,11 +577,12 @@ function parseIdentifier(value) {
|
||||
function recordMatchesIdentifier(record, identifier, mediaType) {
|
||||
const expectedType = mediaType === "movie" ? "movie" : "tv";
|
||||
if (identifier.service === "imdb") {
|
||||
const imdbMatches = (record.imdb_id || []).some((id) => String(id).toLowerCase() === identifier.value);
|
||||
const typeMatches = (record.tmdb_id || []).length === 0 || (record.tmdb_id || []).some((mapping) => mapping.type === expectedType);
|
||||
const imdbMatches = asArray(record.imdb_id).some((id) => String(id).toLowerCase() === identifier.value);
|
||||
const tmdbMappings = asArray(record.tmdb_id);
|
||||
const typeMatches = tmdbMappings.length === 0 || tmdbMappings.some((mapping) => mapping.type === expectedType);
|
||||
return imdbMatches && typeMatches;
|
||||
}
|
||||
return (record.tmdb_id || []).some((mapping) => String(mapping.id) === identifier.value && mapping.type === expectedType);
|
||||
return asArray(record.tmdb_id).some((mapping) => String(mapping.id) === identifier.value && mapping.type === expectedType);
|
||||
}
|
||||
function getAniListIds(records, identifier, mediaType) {
|
||||
const ids = [];
|
||||
@@ -584,7 +591,7 @@ function getAniListIds(records, identifier, mediaType) {
|
||||
if (!recordMatchesIdentifier(record, identifier, mediaType)) {
|
||||
continue;
|
||||
}
|
||||
for (const id of record.anilist_id || []) {
|
||||
for (const id of asArray(record.anilist_id)) {
|
||||
const numericId = asNumber(id);
|
||||
if (numericId && !ids.includes(numericId)) {
|
||||
ids.push(numericId);
|
||||
|
||||
Reference in new issue
Block a user