Feature: Add Various Scraper Fields (#6249)

* Support aliases in stashbox studio query
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Gykes
2025-11-12 15:14:04 -08:00
committed by GitHub
parent b2c8f09585
commit a08d2e258a
9 changed files with 105 additions and 8 deletions

View File

@@ -19,6 +19,9 @@ type ScrapedStudio struct {
Parent *ScrapedStudio `json:"parent"`
Image *string `json:"image"`
Images []string `json:"images"`
Details *string `json:"details"`
Aliases *string `json:"aliases"`
Tags []*ScrapedTag `json:"tags"`
RemoteSiteID *string `json:"remote_site_id"`
}
@@ -55,6 +58,14 @@ func (s *ScrapedStudio) ToStudio(endpoint string, excluded map[string]bool) *Stu
}
}
if s.Details != nil && !excluded["details"] {
ret.Details = *s.Details
}
if s.Aliases != nil && !excluded["aliases"] {
ret.Aliases = NewRelatedStrings(stringslice.FromString(*s.Aliases, ","))
}
if s.Parent != nil && s.Parent.StoredID != nil && !excluded["parent"] && !excluded["parent_studio"] {
parentId, _ := strconv.Atoi(*s.Parent.StoredID)
ret.ParentID = &parentId
@@ -108,6 +119,17 @@ func (s *ScrapedStudio) ToPartial(id string, endpoint string, excluded map[strin
}
}
if s.Details != nil && !excluded["details"] {
ret.Details = NewOptionalString(*s.Details)
}
if s.Aliases != nil && !excluded["aliases"] {
ret.Aliases = &UpdateStrings{
Values: stringslice.FromString(*s.Aliases, ","),
Mode: RelationshipUpdateModeSet,
}
}
if s.Parent != nil && !excluded["parent"] {
if s.Parent.StoredID != nil {
parentID, _ := strconv.Atoi(*s.Parent.StoredID)

View File

@@ -82,11 +82,12 @@ func (t *ImageFragment) GetHeight() int {
}
type StudioFragment struct {
Name string "json:\"name\" graphql:\"name\""
ID string "json:\"id\" graphql:\"id\""
Urls []*URLFragment "json:\"urls\" graphql:\"urls\""
Parent *StudioFragment_Parent "json:\"parent,omitempty\" graphql:\"parent\""
Images []*ImageFragment "json:\"images\" graphql:\"images\""
Name string "json:\"name\" graphql:\"name\""
ID string "json:\"id\" graphql:\"id\""
Aliases []string "json:\"aliases\" graphql:\"aliases\""
Urls []*URLFragment "json:\"urls\" graphql:\"urls\""
Parent *StudioFragment_Parent "json:\"parent,omitempty\" graphql:\"parent\""
Images []*ImageFragment "json:\"images\" graphql:\"images\""
}
func (t *StudioFragment) GetName() string {
@@ -101,6 +102,12 @@ func (t *StudioFragment) GetID() string {
}
return t.ID
}
func (t *StudioFragment) GetAliases() []string {
if t == nil {
t = &StudioFragment{}
}
return t.Aliases
}
func (t *StudioFragment) GetUrls() []*URLFragment {
if t == nil {
t = &StudioFragment{}
@@ -845,6 +852,7 @@ fragment ImageFragment on Image {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}
@@ -980,6 +988,7 @@ fragment ImageFragment on Image {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}
@@ -1115,6 +1124,7 @@ fragment ImageFragment on Image {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}
@@ -1250,6 +1260,7 @@ fragment ImageFragment on Image {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}
@@ -1543,6 +1554,7 @@ fragment ImageFragment on Image {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}
@@ -1641,6 +1653,7 @@ const FindStudioDocument = `query FindStudio ($id: ID, $name: String) {
fragment StudioFragment on Studio {
name
id
aliases
urls {
... URLFragment
}

View File

@@ -2,6 +2,7 @@ package stashbox
import (
"context"
"strings"
"github.com/google/uuid"
"github.com/stashapp/stash/pkg/models"
@@ -63,8 +64,11 @@ func studioFragmentToScrapedStudio(s graphql.StudioFragment) *models.ScrapedStud
images = append(images, image.URL)
}
aliases := strings.Join(s.Aliases, ", ")
st := &models.ScrapedStudio{
Name: s.Name,
Aliases: &aliases,
Images: images,
RemoteSiteID: &s.ID,
}