mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Movie group renames (#5039)
* Rename Movie and MoviePartial to Group/GroupPartial * Rename Movie interfaces * Update movie url builders to use group * Rename movieRoutes to groupRoutes * Update dataloader * Update names in sqlite package * Rename in resolvers * Add GroupByURL to scraper config * Scraper backward compatibility hacks
This commit is contained in:
@@ -26,7 +26,7 @@ type Importer struct {
|
||||
StudioWriter models.StudioFinderCreator
|
||||
GalleryFinder models.GalleryFinder
|
||||
PerformerWriter models.PerformerFinderCreator
|
||||
MovieWriter models.MovieFinderCreator
|
||||
GroupWriter models.GroupFinderCreator
|
||||
TagWriter models.TagFinderCreator
|
||||
Input jsonschema.Scene
|
||||
MissingRefBehaviour models.ImportMissingRefEnum
|
||||
@@ -62,7 +62,7 @@ func (i *Importer) PreImport(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := i.populateMovies(ctx); err != nil {
|
||||
if err := i.populateGroups(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (i *Importer) sceneJSONToScene(sceneJSON jsonschema.Scene) models.Scene {
|
||||
PerformerIDs: models.NewRelatedIDs([]int{}),
|
||||
TagIDs: models.NewRelatedIDs([]int{}),
|
||||
GalleryIDs: models.NewRelatedIDs([]int{}),
|
||||
Movies: models.NewRelatedMovies([]models.MoviesScenes{}),
|
||||
Groups: models.NewRelatedGroups([]models.GroupsScenes{}),
|
||||
StashIDs: models.NewRelatedStashIDs(sceneJSON.StashIDs),
|
||||
}
|
||||
|
||||
@@ -335,24 +335,24 @@ func (i *Importer) createPerformers(ctx context.Context, names []string) ([]*mod
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (i *Importer) populateMovies(ctx context.Context) error {
|
||||
if len(i.Input.Movies) > 0 {
|
||||
for _, inputMovie := range i.Input.Movies {
|
||||
movie, err := i.MovieWriter.FindByName(ctx, inputMovie.MovieName, false)
|
||||
func (i *Importer) populateGroups(ctx context.Context) error {
|
||||
if len(i.Input.Groups) > 0 {
|
||||
for _, inputGroup := range i.Input.Groups {
|
||||
group, err := i.GroupWriter.FindByName(ctx, inputGroup.GroupName, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error finding scene movie: %v", err)
|
||||
return fmt.Errorf("error finding scene group: %v", err)
|
||||
}
|
||||
|
||||
var movieID int
|
||||
if movie == nil {
|
||||
var groupID int
|
||||
if group == nil {
|
||||
if i.MissingRefBehaviour == models.ImportMissingRefEnumFail {
|
||||
return fmt.Errorf("scene movie [%s] not found", inputMovie.MovieName)
|
||||
return fmt.Errorf("scene group [%s] not found", inputGroup.GroupName)
|
||||
}
|
||||
|
||||
if i.MissingRefBehaviour == models.ImportMissingRefEnumCreate {
|
||||
movieID, err = i.createMovie(ctx, inputMovie.MovieName)
|
||||
groupID, err = i.createGroup(ctx, inputGroup.GroupName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating scene movie: %v", err)
|
||||
return fmt.Errorf("error creating scene group: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,35 +361,35 @@ func (i *Importer) populateMovies(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
movieID = movie.ID
|
||||
groupID = group.ID
|
||||
}
|
||||
|
||||
toAdd := models.MoviesScenes{
|
||||
MovieID: movieID,
|
||||
toAdd := models.GroupsScenes{
|
||||
GroupID: groupID,
|
||||
}
|
||||
|
||||
if inputMovie.SceneIndex != 0 {
|
||||
index := inputMovie.SceneIndex
|
||||
if inputGroup.SceneIndex != 0 {
|
||||
index := inputGroup.SceneIndex
|
||||
toAdd.SceneIndex = &index
|
||||
}
|
||||
|
||||
i.scene.Movies.Add(toAdd)
|
||||
i.scene.Groups.Add(toAdd)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Importer) createMovie(ctx context.Context, name string) (int, error) {
|
||||
newMovie := models.NewMovie()
|
||||
newMovie.Name = name
|
||||
func (i *Importer) createGroup(ctx context.Context, name string) (int, error) {
|
||||
newGroup := models.NewGroup()
|
||||
newGroup.Name = name
|
||||
|
||||
err := i.MovieWriter.Create(ctx, &newMovie)
|
||||
err := i.GroupWriter.Create(ctx, &newGroup)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newMovie.ID, nil
|
||||
return newGroup.ID, nil
|
||||
}
|
||||
|
||||
func (i *Importer) populateTags(ctx context.Context) error {
|
||||
|
||||
Reference in New Issue
Block a user