[scraper] fixes featurette and redundant files detection
This commit is contained in:
@@ -123,17 +123,17 @@ function filesAndSizeFromTorrentStream(torrent, timeout = 30000) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function filterVideos(files) {
|
function filterVideos(files) {
|
||||||
const maxSize = Math.max(...files.map(file => file.size));
|
const videos = files.filter(file => isVideo(file.path));
|
||||||
const minSampleRatio = files.length <= 3 ? 5 : 10;
|
const maxSize = Math.max(...videos.map(video => video.size));
|
||||||
const minRedundantRatio = files.length <= 3 ? 30 : Number.MAX_VALUE;
|
const minSampleRatio = videos.length <= 3 ? 5 : 10;
|
||||||
const isSample = file => file.path.match(/sample/i) && maxSize / parseInt(file.size) > minSampleRatio;
|
const minRedundantRatio = videos.length <= 3 ? 30 : Number.MAX_VALUE;
|
||||||
const isRedundant = file => maxSize / parseInt(file.size) > minRedundantRatio;
|
const isSample = video => video.path.match(/sample/i) && maxSize / parseInt(video.size) > minSampleRatio;
|
||||||
const isExtra = file => file.path.match(/extras?\//i);
|
const isRedundant = video => maxSize / parseInt(video.size) > minRedundantRatio;
|
||||||
return files
|
const isExtra = video => video.path.match(/extras?\//i);
|
||||||
.filter(file => isVideo(file.path))
|
return videos
|
||||||
.filter(file => !isSample(file))
|
.filter(video => !isSample(video))
|
||||||
.filter(file => !isExtra(file))
|
.filter(video => !isExtra(video))
|
||||||
.filter(file => !isRedundant(file));
|
.filter(video => !isRedundant(video));
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterSubtitles(files) {
|
function filterSubtitles(files) {
|
||||||
|
|||||||
@@ -47,15 +47,16 @@ async function parseMovieFiles(torrent, parsedName, metadata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parsedVideos = await Promises.sequence(filteredVideos
|
const parsedVideos = await Promises.sequence(filteredVideos
|
||||||
.map(video => () => findMovieImdbId(video.name)
|
.map(video => () => isFeaturette(video)
|
||||||
.then(newImdbId => ({
|
? Promise.resolve(video)
|
||||||
infoHash: torrent.infoHash,
|
: findMovieImdbId(video.name).then(imdbId => ({ ...video, imdbId }))))
|
||||||
fileIndex: video.fileIndex,
|
.then(videos => videos.map(video => ({
|
||||||
title: video.path || video.name,
|
infoHash: torrent.infoHash,
|
||||||
size: video.size,
|
fileIndex: video.fileIndex,
|
||||||
imdbId: newImdbId,
|
title: video.path || video.name,
|
||||||
})))
|
size: video.size,
|
||||||
.map(video => isFeaturette(video) ? clearInfoFields(video) : video));
|
imdbId: video.imdbId,
|
||||||
|
})));
|
||||||
return { contents, videos: parsedVideos, subtitles };
|
return { contents, videos: parsedVideos, subtitles };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user