From 4be60310c3df0c644f4de965280b6287e7098474 Mon Sep 17 00:00:00 2001 From: well <85684982+well-thats-funny@users.noreply.github.com> Date: Tue, 11 Jun 2024 05:41:43 +0200 Subject: [PATCH] In performer scrapers, forward non-http single performer images (#4947) * Forward non-http single performer images * Don't set if Images already set --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com> --- pkg/models/model_scraped_item.go | 2 +- pkg/scraper/image.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/models/model_scraped_item.go b/pkg/models/model_scraped_item.go index b3a7a2418b3..5a9f2acb036 100644 --- a/pkg/models/model_scraped_item.go +++ b/pkg/models/model_scraped_item.go @@ -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"` diff --git a/pkg/scraper/image.go b/pkg/scraper/image.go index 5757bc9b383..78652f11d7e 100644 --- a/pkg/scraper/image.go +++ b/pkg/scraper/image.go @@ -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