mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat(indexers): mam parse vip as freeleech (#407)
This commit is contained in:
parent
7deac6a781
commit
9c036033e9
2 changed files with 32 additions and 2 deletions
|
@ -384,7 +384,7 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if freeleech, err := getStringMapValue(varMap, "freeleech"); err == nil {
|
if freeleech, err := getStringMapValue(varMap, "freeleech"); err == nil {
|
||||||
fl := strings.EqualFold(freeleech, "freeleech") || strings.EqualFold(freeleech, "yes") || strings.EqualFold(freeleech, "1")
|
fl := StringEqualFoldMulti(freeleech, "freeleech", "yes", "1", "VIP")
|
||||||
if fl {
|
if fl {
|
||||||
r.Freeleech = true
|
r.Freeleech = true
|
||||||
r.Bonus = append(r.Bonus, "Freeleech")
|
r.Bonus = append(r.Bonus, "Freeleech")
|
||||||
|
@ -441,7 +441,7 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene, err := getStringMapValue(varMap, "scene"); err == nil {
|
if scene, err := getStringMapValue(varMap, "scene"); err == nil {
|
||||||
r.IsScene = strings.EqualFold(scene, "true") || strings.EqualFold(scene, "yes")
|
r.IsScene = StringEqualFoldMulti(scene, "true", "yes")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set origin. P2P, SCENE, O-SCENE and Internal
|
// set origin. P2P, SCENE, O-SCENE and Internal
|
||||||
|
@ -505,3 +505,12 @@ func SplitAny(s string, seps string) []string {
|
||||||
}
|
}
|
||||||
return strings.FieldsFunc(s, splitter)
|
return strings.FieldsFunc(s, splitter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StringEqualFoldMulti(s string, values ...string) bool {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.EqualFold(s, value) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -444,6 +444,27 @@ func TestRelease_MapVars(t *testing.T) {
|
||||||
"uploader": "Tester",
|
"uploader": "Tester",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "10",
|
||||||
|
fields: &Release{},
|
||||||
|
want: &Release{
|
||||||
|
TorrentName: "Greatest Anime Ever",
|
||||||
|
Year: 2022,
|
||||||
|
Group: "GROUP1",
|
||||||
|
Tags: []string{"comedy", "fantasy", "school.life", "shounen", "slice.of.life"},
|
||||||
|
Uploader: "Tester",
|
||||||
|
Freeleech: true,
|
||||||
|
Bonus: []string{"Freeleech"},
|
||||||
|
},
|
||||||
|
args: args{varMap: map[string]string{
|
||||||
|
"torrentName": "Greatest Anime Ever",
|
||||||
|
"year": "2022",
|
||||||
|
"releaseGroup": "GROUP1",
|
||||||
|
"tags": "comedy, fantasy, school.life, shounen, slice.of.life",
|
||||||
|
"uploader": "Tester",
|
||||||
|
"freeleech": "VIP",
|
||||||
|
}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue