diff --git a/pkg/scraper/cache.go b/pkg/scraper/cache.go index 81607cd44..d526ecb0a 100644 --- a/pkg/scraper/cache.go +++ b/pkg/scraper/cache.go @@ -262,6 +262,9 @@ func (c Cache) ScrapeName(ctx context.Context, id, query string, ty ScrapeConten // ScrapeFragment uses the given fragment input to scrape func (c Cache) ScrapeFragment(ctx context.Context, id string, input Input) (ScrapedContent, error) { + // set the deprecated URL field if it's not set + input.populateURL() + s := c.findScraper(id) if s == nil { return nil, fmt.Errorf("%w: id %s", ErrNotFound, id) diff --git a/pkg/scraper/scraper.go b/pkg/scraper/scraper.go index 67569c18b..23ad411bd 100644 --- a/pkg/scraper/scraper.go +++ b/pkg/scraper/scraper.go @@ -157,6 +157,14 @@ type Input struct { Gallery *ScrapedGalleryInput } +// populateURL populates the URL field of the input based on the +// URLs field of the input. Does nothing if the URL field is already set. +func (i *Input) populateURL() { + if i.Scene != nil && i.Scene.URL == nil && len(i.Scene.URLs) > 0 { + i.Scene.URL = &i.Scene.URLs[0] + } +} + // simple type definitions that can help customize // actions per query type QueryType int diff --git a/pkg/scraper/stash.go b/pkg/scraper/stash.go index f616789c4..da204f347 100644 --- a/pkg/scraper/stash.go +++ b/pkg/scraper/stash.go @@ -324,12 +324,20 @@ func sceneToUpdateInput(scene *models.Scene) models.SceneUpdateInput { // fallback to file basename if title is empty title := scene.GetTitle() + var url *string + urls := scene.URLs.List() + if len(urls) > 0 { + url = &urls[0] + } + return models.SceneUpdateInput{ ID: strconv.Itoa(scene.ID), Title: &title, Details: &scene.Details, - Urls: scene.URLs.List(), - Date: dateToStringPtr(scene.Date), + // include deprecated URL for now + URL: url, + Urls: urls, + Date: dateToStringPtr(scene.Date), } }