mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] clears featurette video files info
This commit is contained in:
@@ -47,29 +47,32 @@ async function parseMovieFiles(torrent, parsedName, metadata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parsedVideos = await Promises.sequence(filteredVideos
|
const parsedVideos = await Promises.sequence(filteredVideos
|
||||||
.map(file => () => findMovieImdbId(file.name)
|
.map(video => () => findMovieImdbId(video.name)
|
||||||
.then(newImdbId => ({
|
.then(newImdbId => ({
|
||||||
infoHash: torrent.infoHash,
|
infoHash: torrent.infoHash,
|
||||||
fileIndex: file.fileIndex,
|
fileIndex: video.fileIndex,
|
||||||
title: file.path || file.name,
|
title: video.path || video.name,
|
||||||
size: file.size,
|
size: video.size,
|
||||||
imdbId: newImdbId,
|
imdbId: newImdbId,
|
||||||
}))));
|
})))
|
||||||
|
.map(video => isFeaturette(video) ? clearInfoFields(video) : video));
|
||||||
return { contents, videos: parsedVideos, subtitles };
|
return { contents, videos: parsedVideos, subtitles };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseSeriesFiles(torrent, parsedName, metadata) {
|
async function parseSeriesFiles(torrent, parsedName, metadata) {
|
||||||
const { contents, videos, subtitles } = await getSeriesTorrentContent(torrent, parsedName);
|
const { contents, videos, subtitles } = await getSeriesTorrentContent(torrent, parsedName);
|
||||||
const parsedVideos = await Promise.resolve(videos)
|
const parsedVideos = await Promise.resolve(videos)
|
||||||
.then((files) => files
|
.then(videos => videos
|
||||||
.filter((file) => file.size > MIN_SIZE)
|
.filter(video => video.size > MIN_SIZE)
|
||||||
.map((file) => parseSeriesFile(file, parsedName, torrent.type)))
|
.map(video => parseSeriesFile(video, parsedName, torrent.type)))
|
||||||
.then((files) => decomposeEpisodes(torrent, files, metadata))
|
.then(videos => decomposeEpisodes(torrent, videos, metadata))
|
||||||
.then((files) => assignKitsuOrImdbEpisodes(torrent, files, metadata))
|
.then(videos => assignKitsuOrImdbEpisodes(torrent, videos, metadata))
|
||||||
.then((files) => Promise.all(files.map(file => file.isMovie
|
.then(videos => Promise.all(videos.map(video => video.isMovie
|
||||||
? mapSeriesMovie(file, torrent)
|
? mapSeriesMovie(video, torrent)
|
||||||
: mapSeriesEpisode(file, torrent, files))))
|
: mapSeriesEpisode(video, torrent, videos))))
|
||||||
.then((files) => files.reduce((a, b) => a.concat(b), []))
|
.then(videos => videos
|
||||||
|
.reduce((a, b) => a.concat(b), [])
|
||||||
|
.map(video => isFeaturette(video) ? clearInfoFields(video) : video))
|
||||||
return { contents, videos: parsedVideos, subtitles };
|
return { contents, videos: parsedVideos, subtitles };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,6 +382,19 @@ function findMovieKitsuId(title) {
|
|||||||
return getKitsuId(parsedTitle, Type.MOVIE).catch(() => undefined);
|
return getKitsuId(parsedTitle, Type.MOVIE).catch(() => undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFeaturette(video) {
|
||||||
|
return /featurettes?\//i.test(video.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearInfoFields(video) {
|
||||||
|
video.imdbId = undefined;
|
||||||
|
video.imdbSeason = undefined;
|
||||||
|
video.imdbEpisode = undefined;
|
||||||
|
video.kitsuId = undefined;
|
||||||
|
video.kitsuEpisode = undefined;
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
|
||||||
function div100(episode) {
|
function div100(episode) {
|
||||||
return (episode / 100 >> 0); // floor to nearest int
|
return (episode / 100 >> 0); // floor to nearest int
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user