mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Feature: Support Multiple URLs in Studios (#6223)
* Backend support for studio URLs * FrontEnd addition * Support URLs in BulkStudioUpdate * Update tagger modal for URLs --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
type FinderImageStashIDGetter interface {
|
||||
models.StudioGetter
|
||||
models.AliasLoader
|
||||
models.URLLoader
|
||||
models.StashIDLoader
|
||||
GetImage(ctx context.Context, studioID int) ([]byte, error)
|
||||
}
|
||||
@@ -22,7 +23,6 @@ type FinderImageStashIDGetter interface {
|
||||
func ToJSON(ctx context.Context, reader FinderImageStashIDGetter, studio *models.Studio) (*jsonschema.Studio, error) {
|
||||
newStudioJSON := jsonschema.Studio{
|
||||
Name: studio.Name,
|
||||
URL: studio.URL,
|
||||
Details: studio.Details,
|
||||
Favorite: studio.Favorite,
|
||||
IgnoreAutoTag: studio.IgnoreAutoTag,
|
||||
@@ -50,6 +50,11 @@ func ToJSON(ctx context.Context, reader FinderImageStashIDGetter, studio *models
|
||||
}
|
||||
newStudioJSON.Aliases = studio.Aliases.List()
|
||||
|
||||
if err := studio.LoadURLs(ctx, reader); err != nil {
|
||||
return nil, fmt.Errorf("loading studio URLs: %w", err)
|
||||
}
|
||||
newStudioJSON.URLs = studio.URLs.List()
|
||||
|
||||
if err := studio.LoadStashIDs(ctx, reader); err != nil {
|
||||
return nil, fmt.Errorf("loading studio stash ids: %w", err)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func createFullStudio(id int, parentID int) models.Studio {
|
||||
ret := models.Studio{
|
||||
ID: id,
|
||||
Name: studioName,
|
||||
URL: url,
|
||||
URLs: models.NewRelatedStrings([]string{url}),
|
||||
Details: details,
|
||||
Favorite: true,
|
||||
CreatedAt: createTime,
|
||||
@@ -84,6 +84,7 @@ func createEmptyStudio(id int) models.Studio {
|
||||
ID: id,
|
||||
CreatedAt: createTime,
|
||||
UpdatedAt: updateTime,
|
||||
URLs: models.NewRelatedStrings([]string{}),
|
||||
Aliases: models.NewRelatedStrings([]string{}),
|
||||
TagIDs: models.NewRelatedIDs([]int{}),
|
||||
StashIDs: models.NewRelatedStashIDs([]models.StashID{}),
|
||||
@@ -93,7 +94,7 @@ func createEmptyStudio(id int) models.Studio {
|
||||
func createFullJSONStudio(parentStudio, image string, aliases []string) *jsonschema.Studio {
|
||||
return &jsonschema.Studio{
|
||||
Name: studioName,
|
||||
URL: url,
|
||||
URLs: []string{url},
|
||||
Details: details,
|
||||
Favorite: true,
|
||||
CreatedAt: json.JSONTime{
|
||||
@@ -120,6 +121,7 @@ func createEmptyJSONStudio() *jsonschema.Studio {
|
||||
Time: updateTime,
|
||||
},
|
||||
Aliases: []string{},
|
||||
URLs: []string{},
|
||||
StashIDs: []models.StashID{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,6 @@ func (i *Importer) Update(ctx context.Context, id int) error {
|
||||
func studioJSONtoStudio(studioJSON jsonschema.Studio) models.Studio {
|
||||
newStudio := models.Studio{
|
||||
Name: studioJSON.Name,
|
||||
URL: studioJSON.URL,
|
||||
Aliases: models.NewRelatedStrings(studioJSON.Aliases),
|
||||
Details: studioJSON.Details,
|
||||
Favorite: studioJSON.Favorite,
|
||||
@@ -229,6 +228,19 @@ func studioJSONtoStudio(studioJSON jsonschema.Studio) models.Studio {
|
||||
StashIDs: models.NewRelatedStashIDs(studioJSON.StashIDs),
|
||||
}
|
||||
|
||||
if len(studioJSON.URLs) > 0 {
|
||||
newStudio.URLs = models.NewRelatedStrings(studioJSON.URLs)
|
||||
} else {
|
||||
urls := []string{}
|
||||
if studioJSON.URL != "" {
|
||||
urls = append(urls, studioJSON.URL)
|
||||
}
|
||||
|
||||
if len(urls) > 0 {
|
||||
newStudio.URLs = models.NewRelatedStrings(urls)
|
||||
}
|
||||
}
|
||||
|
||||
if studioJSON.Rating != 0 {
|
||||
newStudio.Rating = &studioJSON.Rating
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user