mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Scraper fixes (#332)
* Fix panic on invalid xpath * Add missing attrs to scraped performer fragment
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
fragment ScrapedPerformerData on ScrapedPerformer {
|
fragment ScrapedPerformerData on ScrapedPerformer {
|
||||||
name
|
name
|
||||||
url
|
url
|
||||||
|
twitter
|
||||||
|
instagram
|
||||||
birthdate
|
birthdate
|
||||||
ethnicity
|
ethnicity
|
||||||
country
|
country
|
||||||
|
|||||||
@@ -55,7 +55,12 @@ func (s xpathScraperConfig) process(doc *html.Node, common commonXPathConfig) []
|
|||||||
asStr = common.applyCommon(asStr)
|
asStr = common.applyCommon(asStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
found := htmlquery.Find(doc, asStr)
|
found, err := htmlquery.QueryAll(doc, asStr)
|
||||||
|
if err != nil {
|
||||||
|
logger.Warnf("Error parsing xpath expression '%s': %s", asStr, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if len(found) > 0 {
|
if len(found) > 0 {
|
||||||
for i, elem := range found {
|
for i, elem := range found {
|
||||||
if i >= len(ret) {
|
if i >= len(ret) {
|
||||||
|
|||||||
@@ -730,3 +730,20 @@ xPathScrapers:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadInvalidXPath(t *testing.T) {
|
||||||
|
config := make(xpathScraperConfig)
|
||||||
|
|
||||||
|
config["Name"] = `//a[id=']/span`
|
||||||
|
|
||||||
|
reader := strings.NewReader(htmlDoc1)
|
||||||
|
doc, err := htmlquery.Parse(reader)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error loading document: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
common := make(commonXPathConfig)
|
||||||
|
config.process(doc, common)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user