diff --git a/internal/domain/irc.go b/internal/domain/irc.go index 26ce8fa..7a67c92 100644 --- a/internal/domain/irc.go +++ b/internal/domain/irc.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "regexp" "strings" "time" ) @@ -207,6 +208,20 @@ func (p IRCParserOrpheus) Parse(rls *Release, vars map[string]string) error { year := vars["year"] releaseTagsString := vars["releaseTags"] + splittedTags := strings.Split(releaseTagsString, "/") + + // Check and replace the last tag if it's a number between 0 and 100 + if len(splittedTags) > 0 { + lastTag := splittedTags[len(splittedTags)-1] + match, _ := regexp.MatchString(`^\d{1,2}$|^100$`, lastTag) + if match { + splittedTags[len(splittedTags)-1] = lastTag + "%" + } + } + + // Join tags back into a string + releaseTagsString = strings.Join(splittedTags, " ") + //cleanTags := strings.ReplaceAll(releaseTagsString, "/", " ") cleanTags := CleanReleaseTags(releaseTagsString) diff --git a/internal/indexer/indexer_test.go b/internal/indexer/indexer_test.go index 9dff652..5fc4f36 100644 --- a/internal/indexer/indexer_test.go +++ b/internal/indexer/indexer_test.go @@ -79,7 +79,7 @@ func TestIndexersParseAndFilter(t *testing.T) { { name: "announce_2", args: args{ - announceLines: []string{"TORRENT: Dirty Dike – Bogies & Alcohol – [2024] [EP] CD/FLAC/Lossless – hip.hop,uk.hip.hop,united.kingdom – https://orpheus.network/torrents.php?id=0000000 – https://orpheus.network/torrents.php?id=0000000&torrentid=0000000&action=download"}, + announceLines: []string{"TORRENT: Dirty Dike – Bogies & Alcohol – [2024] [EP] CD/FLAC/Lossless/Cue/Log/100 – hip.hop,uk.hip.hop,united.kingdom – https://orpheus.network/torrents.php?id=0000000 – https://orpheus.network/torrents.php?id=0000000&torrentid=0000000&action=download"}, filters: []filterTest{ { filter: &domain.Filter{ @@ -94,6 +94,22 @@ func TestIndexersParseAndFilter(t *testing.T) { }, match: true, }, + { + filter: &domain.Filter{ + Name: "filter_1", + MatchCategories: "EP,Album", + Years: "2024", + Quality: []string{"Lossless"}, + Sources: []string{"CD"}, + Formats: []string{"FLAC"}, + Log: true, + LogScore: 100, + PerfectFlac: true, + Artists: "Dirty Dike", + Albums: "Bogies & Alcohol", + }, + match: true, + }, { filter: &domain.Filter{ Name: "filter_2", @@ -111,6 +127,30 @@ func TestIndexersParseAndFilter(t *testing.T) { }, match: false, }, + { + name: "announce_3", + args: args{ + announceLines: []string{"TORRENT: Dirty Dike – Bogies & Alcohol – [2024] [EP] CD/FLAC/Lossless/Cue/Log/80 – hip.hop,uk.hip.hop,united.kingdom – https://orpheus.network/torrents.php?id=0000000 – https://orpheus.network/torrents.php?id=0000000&torrentid=0000000&action=download"}, + filters: []filterTest{ + { + filter: &domain.Filter{ + Name: "filter_1", + MatchCategories: "EP,Album", + Years: "2024", + Quality: []string{"24bit Lossless"}, + Sources: []string{"CD"}, + Formats: []string{"FLAC"}, + Log: true, + LogScore: 100, + Albums: "Best album", + }, + match: false, + rejections: []string{"albums not matching. got: Bogies & Alcohol want: Best album", "quality not matching. got: [Cue FLAC Lossless Log80 Log] want: [24bit Lossless]", "log score. got 80 want: 100"}, + }, + }, + }, + match: false, + }, }, match: true, },