mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
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:
parent
7cbcc2e14c
commit
956bccd69f
2 changed files with 41 additions and 35 deletions
|
@ -546,6 +546,8 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
||||||
fl := StringEqualFoldMulti(freeleech, "freeleech", "yes", "1", "VIP")
|
fl := StringEqualFoldMulti(freeleech, "freeleech", "yes", "1", "VIP")
|
||||||
if fl {
|
if fl {
|
||||||
r.Freeleech = true
|
r.Freeleech = true
|
||||||
|
// default to 100 and override if freeleechPercent is present in next function
|
||||||
|
r.FreeleechPercent = 100
|
||||||
r.Bonus = append(r.Bonus, "Freeleech")
|
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)
|
//log.Debug().Msgf("bad freeleechPercent var: %v", year)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Freeleech = true
|
if (freeleechPercentInt > 0) {
|
||||||
r.FreeleechPercent = freeleechPercentInt
|
r.Freeleech = true
|
||||||
|
r.FreeleechPercent = freeleechPercentInt
|
||||||
|
|
||||||
r.Bonus = append(r.Bonus, "Freeleech")
|
r.Bonus = append(r.Bonus, "Freeleech")
|
||||||
|
|
||||||
switch freeleechPercentInt {
|
switch freeleechPercentInt {
|
||||||
case 25:
|
case 25:
|
||||||
r.Bonus = append(r.Bonus, "Freeleech25")
|
r.Bonus = append(r.Bonus, "Freeleech25")
|
||||||
case 50:
|
case 50:
|
||||||
r.Bonus = append(r.Bonus, "Freeleech50")
|
r.Bonus = append(r.Bonus, "Freeleech50")
|
||||||
case 75:
|
case 75:
|
||||||
r.Bonus = append(r.Bonus, "Freeleech75")
|
r.Bonus = append(r.Bonus, "Freeleech75")
|
||||||
case 100:
|
case 100:
|
||||||
r.Bonus = append(r.Bonus, "Freeleech100")
|
r.Bonus = append(r.Bonus, "Freeleech100")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if uploader, err := getStringMapValue(varMap, "uploader"); err == nil {
|
if uploader, err := getStringMapValue(varMap, "uploader"); err == nil {
|
||||||
|
|
|
@ -297,12 +297,13 @@ func TestRelease_MapVars(t *testing.T) {
|
||||||
name: "2",
|
name: "2",
|
||||||
fields: &Release{},
|
fields: &Release{},
|
||||||
want: &Release{
|
want: &Release{
|
||||||
TorrentName: "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
TorrentName: "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
||||||
Category: "tv",
|
Category: "tv",
|
||||||
Freeleech: true,
|
Freeleech: true,
|
||||||
Bonus: []string{"Freeleech"},
|
FreeleechPercent: 100,
|
||||||
Uploader: "Anon",
|
Bonus: []string{"Freeleech"},
|
||||||
Size: uint64(10000000000),
|
Uploader: "Anon",
|
||||||
|
Size: uint64(10000000000),
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
varMap: map[string]string{
|
varMap: map[string]string{
|
||||||
|
@ -475,13 +476,14 @@ func TestRelease_MapVars(t *testing.T) {
|
||||||
name: "10",
|
name: "10",
|
||||||
fields: &Release{},
|
fields: &Release{},
|
||||||
want: &Release{
|
want: &Release{
|
||||||
TorrentName: "Greatest Anime Ever",
|
TorrentName: "Greatest Anime Ever",
|
||||||
Year: 2022,
|
Year: 2022,
|
||||||
Group: "GROUP1",
|
Group: "GROUP1",
|
||||||
Tags: []string{"comedy", "fantasy", "school.life", "shounen", "slice.of.life"},
|
Tags: []string{"comedy", "fantasy", "school.life", "shounen", "slice.of.life"},
|
||||||
Uploader: "Tester",
|
Uploader: "Tester",
|
||||||
Freeleech: true,
|
Freeleech: true,
|
||||||
Bonus: []string{"Freeleech"},
|
FreeleechPercent: 100,
|
||||||
|
Bonus: []string{"Freeleech"},
|
||||||
},
|
},
|
||||||
args: args{varMap: map[string]string{
|
args: args{varMap: map[string]string{
|
||||||
"torrentName": "Greatest Anime Ever",
|
"torrentName": "Greatest Anime Ever",
|
||||||
|
@ -496,13 +498,14 @@ func TestRelease_MapVars(t *testing.T) {
|
||||||
name: "11",
|
name: "11",
|
||||||
fields: &Release{},
|
fields: &Release{},
|
||||||
want: &Release{
|
want: &Release{
|
||||||
TorrentName: "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
TorrentName: "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
||||||
Category: "tv",
|
Category: "tv",
|
||||||
Freeleech: true,
|
Freeleech: true,
|
||||||
Bonus: []string{"Freeleech"},
|
FreeleechPercent: 100,
|
||||||
Uploader: "Anon",
|
Bonus: []string{"Freeleech"},
|
||||||
Size: uint64(10000000000),
|
Uploader: "Anon",
|
||||||
Tags: []string{"comedy", "science fiction", "fantasy", "school.life", "shounen", "slice.of.life"},
|
Size: uint64(10000000000),
|
||||||
|
Tags: []string{"comedy", "science fiction", "fantasy", "school.life", "shounen", "slice.of.life"},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
varMap: map[string]string{
|
varMap: map[string]string{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue