From a32b5da9997750299807fcc2883f58a90161cf19 Mon Sep 17 00:00:00 2001 From: NativeRavenclaw <278475762+NativeRavenclaw@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:02:31 +0200 Subject: [PATCH 1/2] Add Path to image scraper args --- pkg/models/image.go | 1 + pkg/scraper/stash.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/models/image.go b/pkg/models/image.go index b99267e8c..1a5d6355f 100644 --- a/pkg/models/image.go +++ b/pkg/models/image.go @@ -79,6 +79,7 @@ type ImageUpdateInput struct { Urls []string `json:"urls"` Date *string `json:"date"` Details *string `json:"details"` + Path *string `json:"path"` Photographer *string `json:"photographer"` Rating100 *int `json:"rating100"` Organized *bool `json:"organized"` diff --git a/pkg/scraper/stash.go b/pkg/scraper/stash.go index 23c4b9063..29c43749c 100644 --- a/pkg/scraper/stash.go +++ b/pkg/scraper/stash.go @@ -459,5 +459,6 @@ func imageToUpdateInput(gallery *models.Image) models.ImageUpdateInput { Details: &gallery.Details, Urls: urls, Date: dateToStringPtr(gallery.Date), + Path: &gallery.Path, } } From d7037ae714f602d7324765c54f4a61b0a47673f9 Mon Sep 17 00:00:00 2001 From: NativeRavenclaw <278475762+NativeRavenclaw@users.noreply.github.com> Date: Thu, 30 Apr 2026 07:40:40 +0200 Subject: [PATCH 2/2] Add a proper imageInput struct for scraper args --- pkg/models/image.go | 1 - pkg/scraper/script.go | 51 ++++++++++++++++++++++++++++++++++++++++++- pkg/scraper/stash.go | 24 -------------------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/pkg/models/image.go b/pkg/models/image.go index 1a5d6355f..b99267e8c 100644 --- a/pkg/models/image.go +++ b/pkg/models/image.go @@ -79,7 +79,6 @@ type ImageUpdateInput struct { Urls []string `json:"urls"` Date *string `json:"date"` Details *string `json:"details"` - Path *string `json:"path"` Photographer *string `json:"photographer"` Rating100 *int `json:"rating100"` Organized *bool `json:"organized"` diff --git a/pkg/scraper/script.go b/pkg/scraper/script.go index f8e47b5d8..49eccee6b 100644 --- a/pkg/scraper/script.go +++ b/pkg/scraper/script.go @@ -205,6 +205,52 @@ func galleryInputFromGallery(gallery *models.Gallery) galleryInput { return ret } +type imageInput struct { + ID string `json:"id"` + Title string `json:"title"` + Urls []string `json:"urls"` + Date *string `json:"date"` + Details string `json:"details"` + + Code string `json:"code,omitempty"` + Photographer string `json:"photographer,omitempty"` + + Files []fileInput `json:"files,omitempty"` +} + +func imageInputFromImage(image *models.Image) imageInput { + dateToStringPtr := func(s *models.Date) *string { + if s != nil { + v := s.String() + return &v + } + + return nil + } + + // fallback to file basename if title is empty + title := image.GetTitle() + urls := image.URLs.List() + + ret := imageInput{ + ID: strconv.Itoa(image.ID), + Title: title, + Urls: urls, + Details: image.Details, + Date: dateToStringPtr(image.Date), + + Code: image.Code, + Photographer: image.Photographer, + } + + for _, f := range image.Files.List() { + fi := fileInputFromFile(*f.Base()) + ret.Files = append(ret.Files, fi) + } + + return ret +} + var ErrScraperScript = errors.New("scraper script error") type scriptScraper struct { @@ -392,6 +438,9 @@ func (s *scriptFragmentScraper) scrapeByFragment(ctx context.Context, input Inpu case input.Scene != nil: inString, err = json.Marshal(*input.Scene) ty = ScrapeContentTypeScene + case input.Image != nil: + inString, err = json.Marshal(*input.Image) + ty = ScrapeContentTypeImage } if err != nil { @@ -430,7 +479,7 @@ func (s *scriptFragmentScraper) scrapeGalleryByGallery(ctx context.Context, gall } func (s *scriptFragmentScraper) scrapeImageByImage(ctx context.Context, image *models.Image) (*models.ScrapedImage, error) { - inString, err := json.Marshal(imageToUpdateInput(image)) + inString, err := json.Marshal(imageInputFromImage(image)) if err != nil { return nil, err diff --git a/pkg/scraper/stash.go b/pkg/scraper/stash.go index 29c43749c..0bf17791c 100644 --- a/pkg/scraper/stash.go +++ b/pkg/scraper/stash.go @@ -438,27 +438,3 @@ func (s *stashScraper) scrapeImageByImage(ctx context.Context, image *models.Ima func (s *stashScraper) scrapeByURL(_ context.Context, _ string, _ ScrapeContentType) (ScrapedContent, error) { return nil, ErrNotSupported } - -func imageToUpdateInput(gallery *models.Image) models.ImageUpdateInput { - dateToStringPtr := func(s *models.Date) *string { - if s != nil { - v := s.String() - return &v - } - - return nil - } - - // fallback to file basename if title is empty - title := gallery.GetTitle() - urls := gallery.URLs.List() - - return models.ImageUpdateInput{ - ID: strconv.Itoa(gallery.ID), - Title: &title, - Details: &gallery.Details, - Urls: urls, - Date: dateToStringPtr(gallery.Date), - Path: &gallery.Path, - } -}