mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
filter watermark files
This commit is contained in:
@@ -29,7 +29,7 @@ async function updateCurrentSeeders(torrentsInput) {
|
|||||||
const torrents = Array.isArray(torrentsInput) ? torrentsInput : [torrentsInput];
|
const torrents = Array.isArray(torrentsInput) ? torrentsInput : [torrentsInput];
|
||||||
const perTorrentResults = Object.fromEntries(new Map(torrents.map(torrent => [torrent.infoHash, {}])));
|
const perTorrentResults = Object.fromEntries(new Map(torrents.map(torrent => [torrent.infoHash, {}])));
|
||||||
const perTrackerInfoHashes = await Promise.all(torrents.map(torrent => getTorrentTrackers(torrent)
|
const perTrackerInfoHashes = await Promise.all(torrents.map(torrent => getTorrentTrackers(torrent)
|
||||||
.then(torrentTrackers => ({ infoHash: torrent.infoHash, trackers: torrentTrackers }))))
|
.then(torrentTrackers => ({ infoHash: torrent.infoHash, trackers: torrentTrackers }))))
|
||||||
.then(allTorrentTrackers => allTorrentTrackers
|
.then(allTorrentTrackers => allTorrentTrackers
|
||||||
.reduce((allTrackersMap, torrentTrackers) => {
|
.reduce((allTrackersMap, torrentTrackers) => {
|
||||||
torrentTrackers.trackers.forEach(tracker =>
|
torrentTrackers.trackers.forEach(tracker =>
|
||||||
@@ -175,11 +175,14 @@ function filterVideos(files) {
|
|||||||
const isExtra = video => video.path.match(/extras?\//i);
|
const isExtra = video => video.path.match(/extras?\//i);
|
||||||
const isAnimeExtra = video => video.path.match(/(?:\b|_)(?:NC)?(?:ED|OP|PV)(?:v?\d\d?)?(?:\b|_)/i)
|
const isAnimeExtra = video => video.path.match(/(?:\b|_)(?:NC)?(?:ED|OP|PV)(?:v?\d\d?)?(?:\b|_)/i)
|
||||||
&& maxSize / parseInt(video.size) > minAnimeExtraRatio;
|
&& maxSize / parseInt(video.size) > minAnimeExtraRatio;
|
||||||
|
const isWatermark = video => video.path.match(/^[A-Z-](?:\.[A-Z])?\.\w{3,4}$/)
|
||||||
|
&& maxSize / parseInt(video.size) > minAnimeExtraRatio
|
||||||
return videos
|
return videos
|
||||||
.filter(video => !isSample(video))
|
.filter(video => !isSample(video))
|
||||||
.filter(video => !isExtra(video))
|
.filter(video => !isExtra(video))
|
||||||
.filter(video => !isAnimeExtra(video))
|
.filter(video => !isAnimeExtra(video))
|
||||||
.filter(video => !isRedundant(video));
|
.filter(video => !isRedundant(video))
|
||||||
|
.filter(video => !isWatermark(video));
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterSubtitles(files) {
|
function filterSubtitles(files) {
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ async function parseMovieFiles(torrent, parsedName, metadata) {
|
|||||||
return { contents, videos: parsedVideos, subtitles };
|
return { contents, videos: parsedVideos, subtitles };
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedVideos = await Promises.sequence(filteredVideos
|
const parsedVideos = await Promises.sequence(filteredVideos.map(video => () => isFeaturette(video)
|
||||||
.map(video => () => isFeaturette(video)
|
|
||||||
? Promise.resolve(video)
|
? Promise.resolve(video)
|
||||||
: findMovieImdbId(video.name).then(imdbId => ({ ...video, imdbId }))))
|
: findMovieImdbId(video.name).then(imdbId => ({ ...video, imdbId }))))
|
||||||
.then(videos => videos.map(video => ({
|
.then(videos => videos.map(video => ({
|
||||||
@@ -78,7 +77,6 @@ async function parseSeriesFiles(torrent, parsedName, metadata) {
|
|||||||
.then(videos => videos
|
.then(videos => videos
|
||||||
.reduce((a, b) => a.concat(b), [])
|
.reduce((a, b) => a.concat(b), [])
|
||||||
.map(video => isFeaturette(video) ? clearInfoFields(video) : video))
|
.map(video => isFeaturette(video) ? clearInfoFields(video) : video))
|
||||||
|
|
||||||
return { contents, videos: parsedVideos, subtitles };
|
return { contents, videos: parsedVideos, subtitles };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +284,7 @@ function decomposeAbsoluteEpisodeFiles(torrent, files, metadata) {
|
|||||||
.filter(file => !file.season || (metadata.episodeCount[file.season - 1] || 0) < file.episodes[0])
|
.filter(file => !file.season || (metadata.episodeCount[file.season - 1] || 0) < file.episodes[0])
|
||||||
.forEach(file => {
|
.forEach(file => {
|
||||||
const seasonIdx = ([...metadata.episodeCount.keys()]
|
const seasonIdx = ([...metadata.episodeCount.keys()]
|
||||||
.find((i) => metadata.episodeCount.slice(0, i + 1).reduce((a, b) => a + b) >= file.episodes[0])
|
.find((i) => metadata.episodeCount.slice(0, i + 1).reduce((a, b) => a + b) >= file.episodes[0])
|
||||||
+ 1 || metadata.episodeCount.length) - 1;
|
+ 1 || metadata.episodeCount.length) - 1;
|
||||||
|
|
||||||
file.season = seasonIdx + 1;
|
file.season = seasonIdx + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user