fix miruro
This commit is contained in:
1 parent
7c58cec433
commit
f502283d6c
3 files changed
+26
-10
No files matched your search
+13
-4
@@ -24,6 +24,14 @@ function asNumber(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();
|
||||
|
||||
@@ -42,17 +50,18 @@ function recordMatchesIdentifier(record, identifier, mediaType) {
|
||||
const expectedType = mediaType === 'movie' ? 'movie' : 'tv';
|
||||
|
||||
if (identifier.service === 'imdb') {
|
||||
const imdbMatches = (record.imdb_id || []).some((id) => (
|
||||
const imdbMatches = asArray(record.imdb_id).some((id) => (
|
||||
String(id).toLowerCase() === identifier.value
|
||||
));
|
||||
const typeMatches = (record.tmdb_id || []).length === 0 || (record.tmdb_id || []).some((mapping) => (
|
||||
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) => (
|
||||
return asArray(record.tmdb_id).some((mapping) => (
|
||||
String(mapping.id) === identifier.value && mapping.type === expectedType
|
||||
));
|
||||
}
|
||||
@@ -70,7 +79,7 @@ function getAniListIds(records, 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)) {
|
||||
|
||||
Reference in new issue
Block a user