Fix sample check rd

This commit is contained in:
Mukhtar Akere
2025-03-31 08:23:11 +01:00
parent f9addaed36
commit 5792305a66
4 changed files with 5 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ var (
MUSICMATCH = "(?i)(\\.)(mp2|mp3|m4a|m4b|m4p|ogg|oga|opus|wma|wav|wv|flac|ape|aif|aiff|aifc)$" 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 { func RegexMatch(regex string, value string) bool {
re := regexp.MustCompile(regex) re := regexp.MustCompile(regex)

View File

@@ -113,7 +113,7 @@ func flattenFiles(files []MagnetFile, parentPath string, index *int) map[string]
fileName := filepath.Base(f.Name) fileName := filepath.Base(f.Name)
// Skip sample files // Skip sample files
if utils.IsSampleFile(fileName) { if utils.IsSampleFile(f.Name) {
continue continue
} }
if !cfg.IsAllowedFile(fileName) { if !cfg.IsAllowedFile(fileName) {

View File

@@ -51,14 +51,13 @@ func getTorrentFiles(t *types.Torrent, data TorrentInfo, validate bool) map[stri
cfg := config.GetConfig() cfg := config.GetConfig()
idx := 0 idx := 0
for _, f := range data.Files { for _, f := range data.Files {
name := filepath.Base(f.Path) name := filepath.Base(f.Path)
if validate { if validate {
if utils.RegexMatch(utils.SAMPLEMATCH, name) { if utils.IsSampleFile(f.Path) {
// Skip sample files // Skip sample files
continue continue
} }
if !cfg.IsAllowedFile(name) { if !cfg.IsAllowedFile(name) {
continue continue
} }

View File

@@ -199,7 +199,7 @@ func (tb *Torbox) UpdateTorrent(t *types.Torrent) error {
cfg := config.GetConfig() cfg := config.GetConfig()
for _, f := range data.Files { for _, f := range data.Files {
fileName := filepath.Base(f.Name) fileName := filepath.Base(f.Name)
if utils.IsSampleFile(fileName) { if utils.IsSampleFile(f.AbsolutePath) {
// Skip sample files // Skip sample files
continue continue
} }