Add gender support for performer (#371)

Co-authored-by: HiddenPants255 <>
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
hiddenpants255
2020-04-01 05:36:38 +07:00
committed by GitHub
parent d886012d74
commit 494b794228
27 changed files with 333 additions and 22 deletions

View File

@@ -3,12 +3,14 @@ package jsonschema
import (
"encoding/json"
"fmt"
"github.com/stashapp/stash/pkg/models"
"os"
"github.com/stashapp/stash/pkg/models"
)
type Performer struct {
Name string `json:"name,omitempty"`
Gender string `json:"gender,omitempty"`
URL string `json:"url,omitempty"`
Twitter string `json:"twitter,omitempty"`
Instagram string `json:"instagram,omitempty"`

View File

@@ -238,6 +238,9 @@ func (t *ExportTask) ExportPerformers(ctx context.Context) {
if performer.Name.Valid {
newPerformerJSON.Name = performer.Name.String
}
if performer.Gender.Valid {
newPerformerJSON.Gender = performer.Gender.String
}
if performer.URL.Valid {
newPerformerJSON.URL = performer.URL.String
}

View File

@@ -94,6 +94,9 @@ func (t *ImportTask) ImportPerformers(ctx context.Context) {
if performerJSON.Name != "" {
newPerformer.Name = sql.NullString{String: performerJSON.Name, Valid: true}
}
if performerJSON.Gender != "" {
newPerformer.Gender = sql.NullString{String: performerJSON.Gender, Valid: true}
}
if performerJSON.URL != "" {
newPerformer.URL = sql.NullString{String: performerJSON.URL, Valid: true}
}
@@ -241,19 +244,19 @@ func (t *ImportTask) ImportMovies(ctx context.Context) {
// Populate a new movie from the input
newMovie := models.Movie{
FrontImage: frontimageData,
BackImage: backimageData,
Checksum: checksum,
Name: sql.NullString{String: movieJSON.Name, Valid: true},
Aliases: sql.NullString{String: movieJSON.Aliases, Valid: true},
Date: models.SQLiteDate{String: movieJSON.Date, Valid: true},
Duration: sql.NullString{String: movieJSON.Duration, Valid: true},
Rating: sql.NullString{String: movieJSON.Rating, Valid: true},
Director: sql.NullString{String: movieJSON.Director, Valid: true},
Synopsis: sql.NullString{String: movieJSON.Synopsis, Valid: true},
URL: sql.NullString{String: movieJSON.URL, Valid: true},
CreatedAt: models.SQLiteTimestamp{Timestamp: t.getTimeFromJSONTime(movieJSON.CreatedAt)},
UpdatedAt: models.SQLiteTimestamp{Timestamp: t.getTimeFromJSONTime(movieJSON.UpdatedAt)},
FrontImage: frontimageData,
BackImage: backimageData,
Checksum: checksum,
Name: sql.NullString{String: movieJSON.Name, Valid: true},
Aliases: sql.NullString{String: movieJSON.Aliases, Valid: true},
Date: models.SQLiteDate{String: movieJSON.Date, Valid: true},
Duration: sql.NullString{String: movieJSON.Duration, Valid: true},
Rating: sql.NullString{String: movieJSON.Rating, Valid: true},
Director: sql.NullString{String: movieJSON.Director, Valid: true},
Synopsis: sql.NullString{String: movieJSON.Synopsis, Valid: true},
URL: sql.NullString{String: movieJSON.URL, Valid: true},
CreatedAt: models.SQLiteTimestamp{Timestamp: t.getTimeFromJSONTime(movieJSON.CreatedAt)},
UpdatedAt: models.SQLiteTimestamp{Timestamp: t.getTimeFromJSONTime(movieJSON.UpdatedAt)},
}
_, err = qb.Create(newMovie, tx)