Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add fields director and (studio) code to scenes #3051

Merged
merged 16 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions graphql/documents/data/scene-slim.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
fragment SlimSceneData on Scene {
id
title
code
details
director
url
date
rating
Expand Down
2 changes: 2 additions & 0 deletions graphql/documents/data/scene.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
fragment SceneData on Scene {
id
title
code
details
director
url
date
rating
Expand Down
4 changes: 4 additions & 0 deletions graphql/documents/data/scrapers.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ fragment ScrapedSceneTagData on ScrapedTag {

fragment ScrapedSceneData on ScrapedScene {
title
code
details
director
url
date
image
Expand Down Expand Up @@ -166,7 +168,9 @@ fragment ScrapedGalleryData on ScrapedGallery {

fragment ScrapedStashBoxSceneData on ScrapedScene {
title
code
details
director
url
date
image
Expand Down
2 changes: 2 additions & 0 deletions graphql/documents/queries/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ query ParseSceneFilenames($filter: FindFilterType!, $config: SceneParserInput!)
...SlimSceneData
}
title
code
details
director
url
date
rating
Expand Down
2 changes: 2 additions & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ input SceneFilterType {
NOT: SceneFilterType

title: StringCriterionInput
code: StringCriterionInput
details: StringCriterionInput
director: StringCriterionInput

"""Filter by file oshash"""
oshash: StringCriterionInput
Expand Down
8 changes: 8 additions & 0 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ type Scene {
checksum: String @deprecated(reason: "Use files.fingerprints")
oshash: String @deprecated(reason: "Use files.fingerprints")
title: String
code: String
details: String
director: String
url: String
date: String
rating: Int
Expand Down Expand Up @@ -76,7 +78,9 @@ input SceneUpdateInput {
clientMutationId: String
id: ID!
title: String
code: String
details: String
director: String
url: String
date: String
rating: Int
Expand Down Expand Up @@ -108,7 +112,9 @@ input BulkSceneUpdateInput {
clientMutationId: String
ids: [ID!]
title: String
code: String
details: String
director: String
url: String
date: String
rating: Int
Expand Down Expand Up @@ -156,7 +162,9 @@ type SceneMovieID {
type SceneParserResult {
scene: Scene!
title: String
code: String
details: String
director: String
url: String
date: String
rating: Int
Expand Down
4 changes: 4 additions & 0 deletions graphql/schema/types/scraper.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ type ScrapedTag {

type ScrapedScene {
title: String
code: String
details: String
director: String
url: String
date: String

Expand All @@ -82,7 +84,9 @@ type ScrapedScene {

input ScrapedSceneInput {
title: String
code: String
details: String
director: String
url: String
date: String

Expand Down
2 changes: 2 additions & 0 deletions graphql/stash-box/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ fragment FingerprintFragment on Fingerprint {
fragment SceneFragment on Scene {
id
title
code
details
director
duration
date
urls {
Expand Down
4 changes: 4 additions & 0 deletions internal/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func (r *mutationResolver) sceneUpdate(ctx context.Context, input models.SceneUp

updatedScene := models.NewScenePartial()
updatedScene.Title = translator.optionalString(input.Title, "title")
updatedScene.Code = translator.optionalString(input.Code, "code")
updatedScene.Details = translator.optionalString(input.Details, "details")
updatedScene.Director = translator.optionalString(input.Director, "director")
updatedScene.URL = translator.optionalString(input.URL, "url")
updatedScene.Date = translator.optionalDate(input.Date, "date")
updatedScene.Rating = translator.optionalInt(input.Rating, "rating")
Expand Down Expand Up @@ -246,7 +248,9 @@ func (r *mutationResolver) BulkSceneUpdate(ctx context.Context, input BulkSceneU

updatedScene := models.NewScenePartial()
updatedScene.Title = translator.optionalString(input.Title, "title")
updatedScene.Code = translator.optionalString(input.Code, "code")
updatedScene.Details = translator.optionalString(input.Details, "details")
updatedScene.Director = translator.optionalString(input.Director, "director")
updatedScene.URL = translator.optionalString(input.URL, "url")
updatedScene.Date = translator.optionalDate(input.Date, "date")
updatedScene.Rating = translator.optionalInt(input.Rating, "rating")
Expand Down
2 changes: 2 additions & 0 deletions internal/manager/filename_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ type SceneParserInput struct {
type SceneParserResult struct {
Scene *models.Scene `json:"scene"`
Title *string `json:"title"`
Code *string `json:"code"`
Details *string `json:"details"`
Director *string `json:"director"`
URL *string `json:"url"`
Date *string `json:"date"`
Rating *int `json:"rating"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/jsonschema/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ type SceneMovie struct {

type Scene struct {
Title string `json:"title,omitempty"`
Code string `json:"code,omitempty"`
Studio string `json:"studio,omitempty"`
URL string `json:"url,omitempty"`
Date string `json:"date,omitempty"`
Rating int `json:"rating,omitempty"`
Organized bool `json:"organized,omitempty"`
OCounter int `json:"o_counter,omitempty"`
Details string `json:"details,omitempty"`
Director string `json:"director,omitempty"`
Galleries []GalleryRef `json:"galleries,omitempty"`
Performers []string `json:"performers,omitempty"`
Movies []SceneMovie `json:"movies,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions pkg/models/model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
type Scene struct {
ID int `json:"id"`
Title string `json:"title"`
Code string `json:"code"`
Details string `json:"details"`
Director string `json:"director"`
URL string `json:"url"`
Date *Date `json:"date"`
Rating *int `json:"rating"`
Expand Down Expand Up @@ -133,7 +135,9 @@ func (s *Scene) LoadRelationships(ctx context.Context, l SceneReader) error {
// the database entry.
type ScenePartial struct {
Title OptionalString
Code OptionalString
Details OptionalString
Director OptionalString
URL OptionalString
Date OptionalDate
Rating OptionalInt
Expand Down Expand Up @@ -167,7 +171,9 @@ type SceneUpdateInput struct {
ClientMutationID *string `json:"clientMutationId"`
ID string `json:"id"`
Title *string `json:"title"`
Code *string `json:"code"`
Details *string `json:"details"`
Director *string `json:"director"`
URL *string `json:"url"`
Date *string `json:"date"`
Rating *int `json:"rating"`
Expand Down Expand Up @@ -200,7 +206,9 @@ func (s ScenePartial) UpdateInput(id int) SceneUpdateInput {
return SceneUpdateInput{
ID: strconv.Itoa(id),
Title: s.Title.Ptr(),
Code: s.Code.Ptr(),
Details: s.Details.Ptr(),
Director: s.Director.Ptr(),
URL: s.URL.Ptr(),
Date: dateStr,
Rating: s.Rating.Ptr(),
Expand Down
6 changes: 6 additions & 0 deletions pkg/models/model_scene_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ func TestScenePartial_UpdateInput(t *testing.T) {

var (
title = "title"
code = "1337"
details = "details"
director = "director"
url = "url"
date = "2001-02-03"
rating = 4
Expand All @@ -35,7 +37,9 @@ func TestScenePartial_UpdateInput(t *testing.T) {
id,
ScenePartial{
Title: NewOptionalString(title),
Code: NewOptionalString(code),
Details: NewOptionalString(details),
Director: NewOptionalString(director),
URL: NewOptionalString(url),
Date: NewOptionalDate(dateObj),
Rating: NewOptionalInt(rating),
Expand All @@ -45,7 +49,9 @@ func TestScenePartial_UpdateInput(t *testing.T) {
SceneUpdateInput{
ID: idStr,
Title: &title,
Code: &code,
Details: &details,
Director: &director,
URL: &url,
Date: &date,
Rating: &rating,
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/model_scraped_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func (ScrapedMovie) IsScrapedContent() {}
type ScrapedItem struct {
ID int `db:"id" json:"id"`
Title sql.NullString `db:"title" json:"title"`
Code sql.NullString `db:"code" json:"code"`
Description sql.NullString `db:"description" json:"description"`
Director sql.NullString `db:"director" json:"director"`
URL sql.NullString `db:"url" json:"url"`
Date SQLiteDate `db:"date" json:"date"`
Rating sql.NullString `db:"rating" json:"rating"`
Expand Down
12 changes: 7 additions & 5 deletions pkg/models/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ type PHashDuplicationCriterionInput struct {
}

type SceneFilterType struct {
And *SceneFilterType `json:"AND"`
Or *SceneFilterType `json:"OR"`
Not *SceneFilterType `json:"NOT"`
Title *StringCriterionInput `json:"title"`
Details *StringCriterionInput `json:"details"`
And *SceneFilterType `json:"AND"`
Or *SceneFilterType `json:"OR"`
Not *SceneFilterType `json:"NOT"`
Title *StringCriterionInput `json:"title"`
Code *StringCriterionInput `json:"code"`
Details *StringCriterionInput `json:"details"`
Director *StringCriterionInput `json:"director"`
// Filter by file oshash
Oshash *StringCriterionInput `json:"oshash"`
// Filter by file checksum
Expand Down
2 changes: 2 additions & 0 deletions pkg/scene/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ type TagFinder interface {
func ToBasicJSON(ctx context.Context, reader CoverGetter, scene *models.Scene) (*jsonschema.Scene, error) {
newSceneJSON := jsonschema.Scene{
Title: scene.Title,
Code: scene.Code,
URL: scene.URL,
Details: scene.Details,
Director: scene.Director,
CreatedAt: json.JSONTime{Time: scene.CreatedAt},
UpdatedAt: json.JSONTime{Time: scene.UpdatedAt},
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/scene/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func (i *Importer) sceneJSONToScene(sceneJSON jsonschema.Scene) models.Scene {
newScene := models.Scene{
// Path: i.Path,
Title: sceneJSON.Title,
Code: sceneJSON.Code,
Details: sceneJSON.Details,
Director: sceneJSON.Director,
URL: sceneJSON.URL,
PerformerIDs: models.NewRelatedIDs([]int{}),
TagIDs: models.NewRelatedIDs([]int{}),
Expand Down
2 changes: 2 additions & 0 deletions pkg/scraper/query_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ func queryURLParametersFromScrapedScene(scene ScrapedSceneInput) queryURLParamet
}

setField("title", scene.Title)
setField("code", scene.Code)
setField("url", scene.URL)
setField("date", scene.Date)
setField("details", scene.Details)
setField("director", scene.Director)
setField("remote_site_id", scene.RemoteSiteID)
return ret
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/scraper/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
)

type ScrapedScene struct {
Title *string `json:"title"`
Details *string `json:"details"`
URL *string `json:"url"`
Date *string `json:"date"`
Title *string `json:"title"`
Code *string `json:"code"`
Details *string `json:"details"`
Director *string `json:"director"`
URL *string `json:"url"`
Date *string `json:"date"`
// This should be a base64 encoded data URL
Image *string `json:"image"`
File *models.SceneFileType `json:"file"`
Expand All @@ -25,7 +27,9 @@ func (ScrapedScene) IsScrapedContent() {}

type ScrapedSceneInput struct {
Title *string `json:"title"`
Code *string `json:"code"`
Details *string `json:"details"`
Director *string `json:"director"`
URL *string `json:"url"`
Date *string `json:"date"`
RemoteSiteID *string `json:"remote_site_id"`
Expand Down
Loading