mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] match subtitles by equals titles instead of includes
This commit is contained in:
@@ -23,22 +23,24 @@ function assignSubtitles({ contents, videos, subtitles }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _parseVideo(video) {
|
function _parseVideo(video) {
|
||||||
|
const fileName = video.title.replace(/\.(\w{2,4})$/, '');
|
||||||
|
const folderName = video.title.replace(/\/?[^/]+$/, '');
|
||||||
return {
|
return {
|
||||||
videoFile: video,
|
videoFile: video,
|
||||||
fileName: video.title.replace(/\.(\w{2,4})$/, ''),
|
fileName: fileName,
|
||||||
folderName: video.title.replace(/\/?[^/]+$/, ''),
|
folderName: folderName,
|
||||||
...parse(video.title)
|
...parse(fileName)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function _mostProbableSubtitleVideo(subtitle, parsedVideos) {
|
function _mostProbableSubtitleVideo(subtitle, parsedVideos) {
|
||||||
const subTitle = subtitle.title || subtitle.path;
|
const subTitle = subtitle.title || subtitle.path;
|
||||||
const parsedSub = parse(subTitle);
|
const parsedSub = parse(subTitle.replace(/\.(\w{2,4})$/, ''));
|
||||||
const byFileName = parsedVideos.filter(video => subTitle.includes(video.fileName));
|
const byFileName = parsedVideos.filter(video => subTitle.includes(video.fileName));
|
||||||
if (byFileName.length === 1) {
|
if (byFileName.length === 1) {
|
||||||
return byFileName[0].videoFile;
|
return byFileName[0].videoFile;
|
||||||
}
|
}
|
||||||
const byTitleSeasonEpisode = parsedVideos.filter(video => parsedSub.title.includes(video.title)
|
const byTitleSeasonEpisode = parsedVideos.filter(video => video.title === parsedSub.title
|
||||||
&& video.seasons === parsedSub.seasons
|
&& video.seasons === parsedSub.seasons
|
||||||
&& JSON.stringify(video.episodes) === JSON.stringify(parsedSub.episodes));
|
&& JSON.stringify(video.episodes) === JSON.stringify(parsedSub.episodes));
|
||||||
if (byTitleSeasonEpisode.length === 1) {
|
if (byTitleSeasonEpisode.length === 1) {
|
||||||
@@ -49,7 +51,7 @@ function _mostProbableSubtitleVideo(subtitle, parsedVideos) {
|
|||||||
if (bySeasonEpisode.length === 1) {
|
if (bySeasonEpisode.length === 1) {
|
||||||
return bySeasonEpisode[0].videoFile;
|
return bySeasonEpisode[0].videoFile;
|
||||||
}
|
}
|
||||||
const byTitle = parsedVideos.filter(video => parsedSub.title.includes(video.title));
|
const byTitle = parsedVideos.filter(video => video.title && video.title === parsedSub.title);
|
||||||
if (byTitle.length === 1) {
|
if (byTitle.length === 1) {
|
||||||
return byTitle[0].videoFile;
|
return byTitle[0].videoFile;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user