mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
fix debrid filename matching for title with non unicode chars
This commit is contained in:
@@ -32,7 +32,7 @@ export async function enrichMeta(itemMeta) {
|
|||||||
poster: commonImdbId && `${METAHUB_URL}/poster/medium/${commonImdbId}/img`,
|
poster: commonImdbId && `${METAHUB_URL}/poster/medium/${commonImdbId}/img`,
|
||||||
background: commonImdbId && `${METAHUB_URL}/background/medium/${commonImdbId}/img`,
|
background: commonImdbId && `${METAHUB_URL}/background/medium/${commonImdbId}/img`,
|
||||||
videos: itemMeta.videos.map(video => {
|
videos: itemMeta.videos.map(video => {
|
||||||
const file = files.find(file => video.title.includes(file.title));
|
const file = files.find(file => sameFilename(video.title, file.title));
|
||||||
if (file?.imdbId) {
|
if (file?.imdbId) {
|
||||||
if (file.imdbSeason && file.imdbEpisode) {
|
if (file.imdbSeason && file.imdbEpisode) {
|
||||||
video.id = `${file.imdbId}:${file.imdbSeason}:${file.imdbEpisode}`;
|
video.id = `${file.imdbId}:${file.imdbSeason}:${file.imdbEpisode}`;
|
||||||
@@ -51,6 +51,16 @@ export async function enrichMeta(itemMeta) {
|
|||||||
return itemMeta
|
return itemMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sameFilename(filename, expectedFilename) {
|
||||||
|
const offset = filename.length - expectedFilename.length;
|
||||||
|
for (let i = 0; i < expectedFilename.length; i++) {
|
||||||
|
if (filename[offset + i] !== expectedFilename[i] && expectedFilename[i] !== '<27>') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function mostCommonValue(array) {
|
function mostCommonValue(array) {
|
||||||
return array.sort((a, b) => array.filter(v => v === a).length - array.filter(v => v === b).length).pop();
|
return array.sort((a, b) => array.filter(v => v === a).length - array.filter(v => v === b).length).pop();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user