mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
fix(releases): improve tags parsing (#459)
This commit is contained in:
parent
bbb8d2fe6e
commit
dc309a57e4
2 changed files with 30 additions and 3 deletions
|
@ -464,8 +464,12 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if tags, err := getStringMapValue(varMap, "tags"); err == nil {
|
if tags, err := getStringMapValue(varMap, "tags"); err == nil {
|
||||||
tagArr := strings.Split(strings.ReplaceAll(tags, " ", ""), ",")
|
tagsArr := []string{}
|
||||||
r.Tags = tagArr
|
s := strings.Split(tags, ",")
|
||||||
|
for _, t := range s {
|
||||||
|
tagsArr = append(tagsArr, strings.Trim(t, " "))
|
||||||
|
}
|
||||||
|
r.Tags = tagsArr
|
||||||
}
|
}
|
||||||
|
|
||||||
if title, err := getStringMapValue(varMap, "title"); err == nil {
|
if title, err := getStringMapValue(varMap, "title"); err == nil {
|
||||||
|
@ -486,7 +490,7 @@ func (r *Release) MapVars(def *IndexerDefinition, varMap map[string]string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if episodeVal, err := getStringMapValue(varMap, "releaseEpisode"); err == nil {
|
if episodeVal, err := getStringMapValue(varMap, "releaseEpisode"); err == nil {
|
||||||
episode, _ := strconv.Atoi(episodeVal);
|
episode, _ := strconv.Atoi(episodeVal)
|
||||||
r.Episode = episode
|
r.Episode = episode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,6 +465,29 @@ func TestRelease_MapVars(t *testing.T) {
|
||||||
"freeleech": "VIP",
|
"freeleech": "VIP",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "11",
|
||||||
|
fields: &Release{},
|
||||||
|
want: &Release{
|
||||||
|
TorrentName: "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
||||||
|
Category: "tv",
|
||||||
|
Freeleech: true,
|
||||||
|
Bonus: []string{"Freeleech"},
|
||||||
|
Uploader: "Anon",
|
||||||
|
Size: uint64(10000000000),
|
||||||
|
Tags: []string{"comedy", "science fiction", "fantasy", "school.life", "shounen", "slice.of.life"},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
varMap: map[string]string{
|
||||||
|
"torrentName": "Good show S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP2",
|
||||||
|
"category": "tv",
|
||||||
|
"tags": "comedy, science fiction, fantasy, school.life, shounen, slice.of.life",
|
||||||
|
"freeleech": "freeleech",
|
||||||
|
"uploader": "Anon",
|
||||||
|
"torrentSize": "10GB",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
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