Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiple images to Performer XPath Scraper #4731

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/scraper/mapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,17 @@ func (s *mappedGalleryScraperConfig) UnmarshalYAML(unmarshal func(interface{}) e

type mappedPerformerScraperConfig struct {
mappedConfig

Tags mappedConfig `yaml:"Tags"`
Images mappedConfig `yaml:"Images"`
Tags mappedConfig `yaml:"Tags"`
}
type _mappedPerformerScraperConfig mappedPerformerScraperConfig

const (
mappedScraperConfigPerformerTags = "Tags"
)
const (
mappedScraperConfigPerformerImages = "Images"
)

func (s *mappedPerformerScraperConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
// HACK - unmarshal to map first, then remove known scene sub-fields, then
Expand All @@ -251,8 +254,10 @@ func (s *mappedPerformerScraperConfig) UnmarshalYAML(unmarshal func(interface{})
thisMap := make(map[string]interface{})

thisMap[mappedScraperConfigPerformerTags] = parentMap[mappedScraperConfigPerformerTags]
thisMap[mappedScraperConfigPerformerImages] = parentMap[mappedScraperConfigPerformerImages]

delete(parentMap, mappedScraperConfigPerformerTags)
delete(parentMap, mappedScraperConfigPerformerImages)

// re-unmarshal the sub-fields
yml, err := yaml.Marshal(thisMap)
Expand Down Expand Up @@ -838,6 +843,7 @@ func (s mappedScraper) scrapePerformer(ctx context.Context, q mappedQuery) (*mod
}

performerTagsMap := performerMap.Tags
performerImagesMap := performerMap.Images

results := performerMap.process(ctx, q, s.Common)

Expand All @@ -853,6 +859,13 @@ func (s mappedScraper) scrapePerformer(ctx context.Context, q mappedQuery) (*mod
}
}

if performerImagesMap != nil {
imageResults := performerImagesMap.process(ctx, q, s.Common)
for _, p := range imageResults {
ret.Images = append(ret.Images, p["URL"])
}
}

if len(results) == 0 && len(ret.Tags) == 0 {
return nil, nil
}
Expand Down
Loading