fix(filters): RED and OPS lossless parsing and filtering (#1373)

* fix(filters): RED and OPS lossless parsing and filtering

* fix(filters): logscore and EP parsing

* fix(filters): tests

* fix(filters): tests

* feat(definitions): RED parse title variable

* feat(indexers): setup indexer to filter tests

* feat(indexers): tests and improve parsing

* feat(indexers): improve tests
This commit is contained in:
ze0s 2024-01-28 22:03:25 +01:00 committed by GitHub
parent 9db5a8b116
commit 5328078b32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1093 additions and 360 deletions

View file

@ -12,7 +12,6 @@ import (
"net/http"
"net/http/cookiejar"
"os"
"regexp"
"strconv"
"strings"
"time"
@ -75,6 +74,8 @@ type Release struct {
HDR []string `json:"hdr"`
Audio []string `json:"-"`
AudioChannels string `json:"-"`
AudioFormat string `json:"-"`
Bitrate string `json:"-"`
Group string `json:"group"`
Region string `json:"-"`
Language []string `json:"-"`
@ -84,6 +85,8 @@ type Release struct {
Artists string `json:"-"`
Type string `json:"type"` // Album,Single,EP
LogScore int `json:"-"`
HasCue bool `json:"-"`
HasLog bool `json:"-"`
Origin string `json:"origin"` // P2P, Internal
Tags []string `json:"-"`
ReleaseTags string `json:"-"`
@ -289,6 +292,8 @@ func NewRelease(indexer string) *Release {
func (r *Release) ParseString(title string) {
rel := rls.ParseString(title)
r.Type = rel.Type.String()
r.TorrentName = title
r.Source = rel.Source
r.Resolution = rel.Resolution
@ -327,18 +332,40 @@ func (r *Release) ParseString(title string) {
var ErrUnrecoverableError = errors.New("unrecoverable error")
func (r *Release) ParseReleaseTagsString(tags string) {
// trim delimiters and closest space
re := regexp.MustCompile(`\| |/ |, `)
cleanTags := re.ReplaceAllString(tags, "")
cleanTags := CleanReleaseTags(tags)
t := ParseReleaseTagString(cleanTags)
if len(t.Audio) > 0 {
r.Audio = getUniqueTags(r.Audio, t.Audio)
//r.Audio = getUniqueTags(r.Audio, t.Audio)
r.Audio = t.Audio
}
if t.AudioBitrate != "" {
r.Bitrate = t.AudioBitrate
}
if t.AudioFormat != "" {
r.AudioFormat = t.AudioFormat
}
if r.AudioChannels == "" && t.Channels != "" {
r.AudioChannels = t.Channels
}
if t.HasLog {
r.HasLog = true
if t.LogScore > 0 {
r.LogScore = t.LogScore
}
}
if t.HasCue {
r.HasCue = true
}
if len(t.Bonus) > 0 {
if sliceContainsSlice([]string{"Freeleech"}, t.Bonus) {
if sliceContainsSlice([]string{"Freeleech", "Freeleech!"}, t.Bonus) {
r.Freeleech = true
}
// TODO handle percent and other types
@ -363,9 +390,6 @@ func (r *Release) ParseReleaseTagsString(tags string) {
if r.Source == "" && t.Source != "" {
r.Source = t.Source
}
if r.AudioChannels == "" && t.Channels != "" {
r.AudioChannels = t.Channels
}
}
// ParseSizeBytesString If there are parsing errors, then it keeps the original (or default size 0)