mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Refactor scraping to include related object fields (#6266)
* Refactor scraper post-processing and process related objects consistently * Refactor image processing * Scrape related studio fields consistently * Don't set image on related objects
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/match"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/sliceutil"
|
||||
"github.com/stashapp/stash/pkg/txn"
|
||||
)
|
||||
|
||||
@@ -262,19 +261,23 @@ func (c Cache) ScrapeName(ctx context.Context, id, query string, ty ScrapeConten
|
||||
return nil, fmt.Errorf("error while name scraping with scraper %s: %w", id, err)
|
||||
}
|
||||
|
||||
ignoredRegex := c.compileExcludeTagPatterns()
|
||||
|
||||
var ignoredTags []string
|
||||
for i, cc := range content {
|
||||
var thisIgnoredTags []string
|
||||
content[i], thisIgnoredTags, err = c.postScrape(ctx, cc, ignoredRegex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while post-scraping with scraper %s: %w", id, err)
|
||||
pp := postScraper{
|
||||
Cache: c,
|
||||
excludeTagRE: c.compileExcludeTagPatterns(),
|
||||
}
|
||||
if err := c.repository.WithReadTxn(ctx, func(ctx context.Context) error {
|
||||
for i, cc := range content {
|
||||
content[i], err = pp.postScrape(ctx, cc)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while post-scraping with scraper %s: %w", id, err)
|
||||
}
|
||||
}
|
||||
ignoredTags = sliceutil.AppendUniques(ignoredTags, thisIgnoredTags)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
LogIgnoredTags(ignoredTags)
|
||||
LogIgnoredTags(pp.ignoredTags)
|
||||
|
||||
return content, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user