mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Stash box client interface (#751)
* Add gql client generation files * Update dependencies * Add stash-box client generation to the makefile * Move scraped scene object matchers to models * Add stash-box to scrape with dropdown * Add scrape scene from fingerprint in UI
This commit is contained in:
87
pkg/models/scraped.go
Normal file
87
pkg/models/scraped.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package models
|
||||
|
||||
import "strconv"
|
||||
|
||||
// MatchScrapedScenePerformer matches the provided performer with the
|
||||
// performers in the database and sets the ID field if one is found.
|
||||
func MatchScrapedScenePerformer(p *ScrapedScenePerformer) error {
|
||||
qb := NewPerformerQueryBuilder()
|
||||
|
||||
performers, err := qb.FindByNames([]string{p.Name}, nil, true)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(performers) != 1 {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(performers[0].ID)
|
||||
p.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatchScrapedSceneStudio matches the provided studio with the studios
|
||||
// in the database and sets the ID field if one is found.
|
||||
func MatchScrapedSceneStudio(s *ScrapedSceneStudio) error {
|
||||
qb := NewStudioQueryBuilder()
|
||||
|
||||
studio, err := qb.FindByName(s.Name, nil, true)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if studio == nil {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(studio.ID)
|
||||
s.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatchScrapedSceneMovie matches the provided movie with the movies
|
||||
// in the database and sets the ID field if one is found.
|
||||
func MatchScrapedSceneMovie(m *ScrapedSceneMovie) error {
|
||||
qb := NewMovieQueryBuilder()
|
||||
|
||||
movies, err := qb.FindByNames([]string{m.Name}, nil, true)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(movies) != 1 {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(movies[0].ID)
|
||||
m.ID = &id
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatchScrapedSceneTag matches the provided tag with the tags
|
||||
// in the database and sets the ID field if one is found.
|
||||
func MatchScrapedSceneTag(s *ScrapedSceneTag) error {
|
||||
qb := NewTagQueryBuilder()
|
||||
|
||||
tag, err := qb.FindByName(s.Name, nil, true)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if tag == nil {
|
||||
// ignore - cannot match
|
||||
return nil
|
||||
}
|
||||
|
||||
id := strconv.Itoa(tag.ID)
|
||||
s.ID = &id
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user