From 5792305a66506e762ee1d73055209c381ebc8277 Mon Sep 17 00:00:00 2001 From: Mukhtar Akere Date: Mon, 31 Mar 2025 08:23:11 +0100 Subject: [PATCH] Fix sample check rd --- internal/utils/regex.go | 2 +- pkg/debrid/alldebrid/alldebrid.go | 2 +- pkg/debrid/realdebrid/realdebrid.go | 5 ++--- pkg/debrid/torbox/torbox.go | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/utils/regex.go b/internal/utils/regex.go index ae4fd8d..6a9031a 100644 --- a/internal/utils/regex.go +++ b/internal/utils/regex.go @@ -11,7 +11,7 @@ var ( MUSICMATCH = "(?i)(\\.)(mp2|mp3|m4a|m4b|m4p|ogg|oga|opus|wma|wav|wv|flac|ape|aif|aiff|aifc)$" ) -var SAMPLEMATCH = `(?i)(^|[\\/]|[._-])(sample|trailer|thumb)s?([._-]|$)` +var SAMPLEMATCH = `(?i)(^|[\\/]|\s|[._-])(sample|trailer|thumb|special|extras?)s?(\s|[._-]|$|/)` func RegexMatch(regex string, value string) bool { re := regexp.MustCompile(regex) diff --git a/pkg/debrid/alldebrid/alldebrid.go b/pkg/debrid/alldebrid/alldebrid.go index a36e51f..27d0ef2 100644 --- a/pkg/debrid/alldebrid/alldebrid.go +++ b/pkg/debrid/alldebrid/alldebrid.go @@ -113,7 +113,7 @@ func flattenFiles(files []MagnetFile, parentPath string, index *int) map[string] fileName := filepath.Base(f.Name) // Skip sample files - if utils.IsSampleFile(fileName) { + if utils.IsSampleFile(f.Name) { continue } if !cfg.IsAllowedFile(fileName) { diff --git a/pkg/debrid/realdebrid/realdebrid.go b/pkg/debrid/realdebrid/realdebrid.go index 09cfe8e..ca61d58 100644 --- a/pkg/debrid/realdebrid/realdebrid.go +++ b/pkg/debrid/realdebrid/realdebrid.go @@ -51,14 +51,13 @@ func getTorrentFiles(t *types.Torrent, data TorrentInfo, validate bool) map[stri cfg := config.GetConfig() idx := 0 for _, f := range data.Files { - name := filepath.Base(f.Path) - if validate { - if utils.RegexMatch(utils.SAMPLEMATCH, name) { + if utils.IsSampleFile(f.Path) { // Skip sample files continue } + if !cfg.IsAllowedFile(name) { continue } diff --git a/pkg/debrid/torbox/torbox.go b/pkg/debrid/torbox/torbox.go index 24dc60f..2396a24 100644 --- a/pkg/debrid/torbox/torbox.go +++ b/pkg/debrid/torbox/torbox.go @@ -199,7 +199,7 @@ func (tb *Torbox) UpdateTorrent(t *types.Torrent) error { cfg := config.GetConfig() for _, f := range data.Files { fileName := filepath.Base(f.Name) - if utils.IsSampleFile(fileName) { + if utils.IsSampleFile(f.AbsolutePath) { // Skip sample files continue }