mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Discard null values from scraper results (#1374)
This commit is contained in:
parent
c73025c86d
commit
bc9aa02835
2 changed files with 17 additions and 4 deletions
|
|
@ -75,7 +75,7 @@ func (s mappedConfig) postProcess(q mappedQuery, attrConfig mappedScraperAttrCon
|
||||||
result = attrConfig.postProcess(result, q)
|
result = attrConfig.postProcess(result, q)
|
||||||
if attrConfig.hasSplit() {
|
if attrConfig.hasSplit() {
|
||||||
results := attrConfig.splitString(result)
|
results := attrConfig.splitString(result)
|
||||||
results = attrConfig.distinctResults(results)
|
results = attrConfig.cleanResults(results)
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ func (s mappedConfig) postProcess(q mappedQuery, attrConfig mappedScraperAttrCon
|
||||||
|
|
||||||
ret = append(ret, text)
|
ret = append(ret, text)
|
||||||
}
|
}
|
||||||
ret = attrConfig.distinctResults(ret)
|
ret = attrConfig.cleanResults(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
@ -643,8 +643,10 @@ func (c mappedScraperAttrConfig) concatenateResults(nodes []string) string {
|
||||||
return strings.Join(result, separator)
|
return strings.Join(result, separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c mappedScraperAttrConfig) distinctResults(nodes []string) []string {
|
func (c mappedScraperAttrConfig) cleanResults(nodes []string) []string {
|
||||||
return utils.StrUnique(nodes)
|
cleaned := utils.StrUnique(nodes) // remove duplicate values
|
||||||
|
cleaned = utils.StrDelete(cleaned, "") // remove empty values
|
||||||
|
return cleaned
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c mappedScraperAttrConfig) splitString(value string) []string {
|
func (c mappedScraperAttrConfig) splitString(value string) []string {
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,17 @@ func StrUnique(vs []string) []string {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StrDelete returns the vs string slice with toDel values removed.
|
||||||
|
func StrDelete(vs []string, toDel string) []string {
|
||||||
|
var ret []string
|
||||||
|
for _, v := range vs {
|
||||||
|
if v != toDel {
|
||||||
|
ret = append(ret, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
// StringSliceToIntSlice converts a slice of strings to a slice of ints.
|
// StringSliceToIntSlice converts a slice of strings to a slice of ints.
|
||||||
// Returns an error if any values cannot be parsed.
|
// Returns an error if any values cannot be parsed.
|
||||||
func StringSliceToIntSlice(ss []string) ([]int, error) {
|
func StringSliceToIntSlice(ss []string) ([]int, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue