From cf5704aad4da5053457fdd7cff900a6cc0a23d3c Mon Sep 17 00:00:00 2001 From: nuxen Date: Fri, 8 Nov 2024 17:20:57 +0100 Subject: [PATCH] fix(processor): don't match sample in torrents --- internal/http/processor.go | 2 +- internal/release/release.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/http/processor.go b/internal/http/processor.go index 5622ec9..2b54f69 100644 --- a/internal/http/processor.go +++ b/internal/http/processor.go @@ -275,7 +275,7 @@ func (p *processor) processSeasonPack() (domain.StatusCode, error) { var fileName string var size int64 for _, f := range *torrentFiles { - if filepath.Ext(f.Name) != ".mkv" { + if !release.IsValidEpisodeFile(f.Name) { continue } diff --git a/internal/release/release.go b/internal/release/release.go index dd66500..4ec737d 100644 --- a/internal/release/release.go +++ b/internal/release/release.go @@ -152,3 +152,19 @@ func PercentOfTotalEpisodes(totalEps int, foundEps int) float32 { return float32(foundEps) / float32(totalEps) } + +func IsValidEpisodeFile(torrentFileName string) bool { + torrentFileRls := rls.ParseString(filepath.Base(torrentFileName)) + + // ignore non video files + if torrentFileRls.Ext != "mkv" { + return false + } + + // ignore sample files + if rls.MustNormalize(torrentFileRls.Group) == "sample" { + return false + } + + return true +}