mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Tag aliases (#1412)
* Add Tag Update/UpdateFull * Tag alias implementation * Refactor tag page * Add aliases in UI * Include tag aliases in q filter * Include aliases in tag select * Add aliases to auto-tagger * Use aliases in scraper * Add tag aliases for filename parser
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/tag"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
@@ -583,7 +584,7 @@ func (p *SceneFilenameParser) queryMovie(qb models.MovieReader, movieName string
|
||||
}
|
||||
|
||||
func (p *SceneFilenameParser) queryTag(qb models.TagReader, tagName string) *models.Tag {
|
||||
// massage the performer name
|
||||
// massage the tag name
|
||||
tagName = delimiterRE.ReplaceAllString(tagName, " ")
|
||||
|
||||
// check cache first
|
||||
@@ -592,7 +593,12 @@ func (p *SceneFilenameParser) queryTag(qb models.TagReader, tagName string) *mod
|
||||
}
|
||||
|
||||
// match tag name exactly
|
||||
ret, _ := qb.FindByName(tagName, true)
|
||||
ret, _ := tag.ByName(qb, tagName)
|
||||
|
||||
// try to match on alias
|
||||
if ret == nil {
|
||||
ret, _ = tag.ByAlias(qb, tagName)
|
||||
}
|
||||
|
||||
// add result to cache
|
||||
p.tagCache[tagName] = ret
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
type Tag struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Aliases []string `json:"aliases,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
CreatedAt models.JSONTime `json:"created_at,omitempty"`
|
||||
UpdatedAt models.JSONTime `json:"updated_at,omitempty"`
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package manager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func EnsureTagNameUnique(tag models.Tag, qb models.TagReader) error {
|
||||
// ensure name is unique
|
||||
sameNameTag, err := qb.FindByName(tag.Name, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if sameNameTag != nil && tag.ID != sameNameTag.ID {
|
||||
return fmt.Errorf("Tag with name '%s' already exists", tag.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -276,13 +276,18 @@ func (j *autoTagJob) autoTagTags(ctx context.Context, progress *job.Progress, pa
|
||||
}
|
||||
|
||||
if err := j.txnManager.WithTxn(context.TODO(), func(r models.Repository) error {
|
||||
if err := autotag.TagScenes(tag, paths, r.Scene()); err != nil {
|
||||
aliases, err := r.Tag().GetAliases(tag.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := autotag.TagImages(tag, paths, r.Image()); err != nil {
|
||||
|
||||
if err := autotag.TagScenes(tag, paths, aliases, r.Scene()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := autotag.TagGalleries(tag, paths, r.Gallery()); err != nil {
|
||||
if err := autotag.TagImages(tag, paths, aliases, r.Image()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := autotag.TagGalleries(tag, paths, aliases, r.Gallery()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user