Skip to content

Commit

Permalink
In performer scrapers, forward non-http single performer images (stas…
Browse files Browse the repository at this point in the history
…happ#4947)

* Forward non-http single performer images
* Don't set if Images already set
---------
Co-authored-by: WithoutPants <[email protected]>
  • Loading branch information
well-thats-funny authored Jun 11, 2024
1 parent 2d483f2 commit 4be6031
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/models/model_scraped_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type ScrapedPerformer struct {
Aliases *string `json:"aliases"`
Tags []*ScrapedTag `json:"tags"`
// This should be a base64 encoded data URL
Image *string `json:"image"`
Image *string `json:"image"` // deprecated: use Images
Images []string `json:"images"`
Details *string `json:"details"`
DeathDate *string `json:"death_date"`
Expand Down
10 changes: 9 additions & 1 deletion pkg/scraper/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ import (
)

func setPerformerImage(ctx context.Context, client *http.Client, p *models.ScrapedPerformer, globalConfig GlobalConfig) error {
if p.Image == nil || !strings.HasPrefix(*p.Image, "http") {
// backwards compatibility: we fetch the image if it's a URL and set it to the first image
// Image is deprecated, so only do this if Images is unset
if p.Image == nil || len(p.Images) > 0 {
// nothing to do
return nil
}

// don't try to get the image if it doesn't appear to be a URL
if !strings.HasPrefix(*p.Image, "http") {
p.Images = []string{*p.Image}
return nil
}

img, err := getImage(ctx, *p.Image, client, globalConfig)
if err != nil {
return err
Expand Down

0 comments on commit 4be6031

Please sign in to comment.