feat(releases): set freeleech percent 100 with freeleech bool (#872)

* feat(releases): set freeleech to freeleech percent 100

* fix(releases): check if freeleechpercent is gt 0
This commit is contained in:
ze0s 2023-04-23 20:54:39 +02:00 committed by GitHub
parent 7cbcc2e14c
commit 956bccd69f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 35 deletions

View file

@ -546,6 +546,8 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
fl := StringEqualFoldMulti(freeleech, "freeleech", "yes", "1", "VIP")
if fl {
r.Freeleech = true
// default to 100 and override if freeleechPercent is present in next function
r.FreeleechPercent = 100
r.Bonus = append(r.Bonus, "Freeleech")
}
}
@ -560,22 +562,23 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
//log.Debug().Msgf("bad freeleechPercent var: %v", year)
}
r.Freeleech = true
r.FreeleechPercent = freeleechPercentInt
r.Bonus = append(r.Bonus, "Freeleech")
switch freeleechPercentInt {
case 25:
r.Bonus = append(r.Bonus, "Freeleech25")
case 50:
r.Bonus = append(r.Bonus, "Freeleech50")
case 75:
r.Bonus = append(r.Bonus, "Freeleech75")
case 100:
r.Bonus = append(r.Bonus, "Freeleech100")
if (freeleechPercentInt > 0) {
r.Freeleech = true
r.FreeleechPercent = freeleechPercentInt
r.Bonus = append(r.Bonus, "Freeleech")
switch freeleechPercentInt {
case 25:
r.Bonus = append(r.Bonus, "Freeleech25")
case 50:
r.Bonus = append(r.Bonus, "Freeleech50")
case 75:
r.Bonus = append(r.Bonus, "Freeleech75")
case 100:
r.Bonus = append(r.Bonus, "Freeleech100")
}
}
}
if uploader, err := getStringMapValue(varMap, "uploader"); err == nil {