mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Include old URL in script input (#3940)
* Include old URL in script input * Include URL in update input
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user