feat(indexers): BHD freeleech announces (#1216)

* feat(indexers): BHD freeleech announces

* feat: parse and map bhd freeleech

---------

Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
martylukyy 2023-10-26 22:30:28 +02:00 committed by GitHub
parent c866f167f7
commit d1fa1b7cdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -656,7 +656,7 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
}
if freeleech, err := getStringMapValue(varMap, "freeleech"); err == nil {
fl := StringEqualFoldMulti(freeleech, "freeleech", "yes", "1", "VIP")
fl := StringEqualFoldMulti(freeleech, "freeleech", "freeleech!", "yes", "1", "VIP")
if fl {
r.Freeleech = true
// default to 100 and override if freeleechPercent is present in next function
@ -666,6 +666,15 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
}
if freeleechPercent, err := getStringMapValue(varMap, "freeleechPercent"); err == nil {
// special handling for BHD to map their freeleech into percent
if def.Identifier == "beyondhd" {
if freeleechPercent == "Capped FL" {
freeleechPercent = "100%"
} else if strings.Contains(freeleechPercent, "% FL") {
freeleechPercent = strings.Replace(freeleechPercent, " FL", "", -1)
}
}
// remove % and trim spaces
freeleechPercent = strings.Replace(freeleechPercent, "%", "", -1)
freeleechPercent = strings.Trim(freeleechPercent, " ")