diff --git a/graphql/documents/data/scrapers.graphql b/graphql/documents/data/scrapers.graphql index 2a46cc155..e9c8f324b 100644 --- a/graphql/documents/data/scrapers.graphql +++ b/graphql/documents/data/scrapers.graphql @@ -1,5 +1,6 @@ fragment ScrapedPerformerData on ScrapedPerformer { name + gender url twitter instagram @@ -20,6 +21,7 @@ fragment ScrapedPerformerData on ScrapedPerformer { fragment ScrapedScenePerformerData on ScrapedScenePerformer { id name + gender url twitter instagram @@ -45,7 +47,6 @@ fragment ScrapedMovieData on ScrapedMovie { director url synopsis - } fragment ScrapedSceneMovieData on ScrapedSceneMovie { diff --git a/graphql/schema/types/scraped-performer.graphql b/graphql/schema/types/scraped-performer.graphql index e57c7a2e3..d991ed327 100644 --- a/graphql/schema/types/scraped-performer.graphql +++ b/graphql/schema/types/scraped-performer.graphql @@ -1,6 +1,7 @@ """A performer from a scraping operation...""" type ScrapedPerformer { name: String + gender: String url: String twitter: String instagram: String @@ -22,6 +23,7 @@ type ScrapedPerformer { input ScrapedPerformerInput { name: String + gender: String url: String twitter: String instagram: String diff --git a/graphql/schema/types/scraper.graphql b/graphql/schema/types/scraper.graphql index 601621c61..69c050a63 100644 --- a/graphql/schema/types/scraper.graphql +++ b/graphql/schema/types/scraper.graphql @@ -27,6 +27,7 @@ type ScrapedScenePerformer { """Set if performer matched""" id: ID name: String! + gender: String url: String twitter: String instagram: String @@ -54,7 +55,6 @@ type ScrapedSceneMovie { director: String synopsis: String url: String - } type ScrapedSceneStudio { diff --git a/pkg/models/model_scraped_item.go b/pkg/models/model_scraped_item.go index e09418e61..719274b5f 100644 --- a/pkg/models/model_scraped_item.go +++ b/pkg/models/model_scraped_item.go @@ -25,6 +25,7 @@ type ScrapedItem struct { type ScrapedPerformer struct { Name *string `graphql:"name" json:"name"` + Gender *string `graphql:"gender" json:"gender"` URL *string `graphql:"url" json:"url"` Twitter *string `graphql:"twitter" json:"twitter"` Instagram *string `graphql:"instagram" json:"instagram"` @@ -45,6 +46,7 @@ type ScrapedPerformer struct { // this type has no Image field type ScrapedPerformerStash struct { Name *string `graphql:"name" json:"name"` + Gender *string `graphql:"gender" json:"gender"` URL *string `graphql:"url" json:"url"` Twitter *string `graphql:"twitter" json:"twitter"` Instagram *string `graphql:"instagram" json:"instagram"` @@ -91,6 +93,7 @@ type ScrapedScenePerformer struct { // Set if performer matched ID *string `graphql:"id" json:"id"` Name string `graphql:"name" json:"name"` + Gender *string `graphql:"gender" json:"gender"` URL *string `graphql:"url" json:"url"` Twitter *string `graphql:"twitter" json:"twitter"` Instagram *string `graphql:"instagram" json:"instagram"` @@ -116,15 +119,15 @@ type ScrapedSceneStudio struct { type ScrapedSceneMovie struct { // Set if movie matched - ID *string `graphql:"id" json:"id"` - Name string `graphql:"name" json:"name"` - Aliases string `graphql:"aliases" json:"aliases"` - Duration string `graphql:"duration" json:"duration"` - Date string `graphql:"date" json:"date"` - Rating string `graphql:"rating" json:"rating"` - Director string `graphql:"director" json:"director"` - Synopsis string `graphql:"synopsis" json:"synopsis"` - URL *string `graphql:"url" json:"url"` + ID *string `graphql:"id" json:"id"` + Name string `graphql:"name" json:"name"` + Aliases string `graphql:"aliases" json:"aliases"` + Duration string `graphql:"duration" json:"duration"` + Date string `graphql:"date" json:"date"` + Rating string `graphql:"rating" json:"rating"` + Director string `graphql:"director" json:"director"` + Synopsis string `graphql:"synopsis" json:"synopsis"` + URL *string `graphql:"url" json:"url"` } type ScrapedSceneTag struct { diff --git a/ui/v2.5/src/components/Performers/PerformerDetails/PerformerDetailsPanel.tsx b/ui/v2.5/src/components/Performers/PerformerDetails/PerformerDetailsPanel.tsx index b9dda1de6..a5e279c96 100644 --- a/ui/v2.5/src/components/Performers/PerformerDetails/PerformerDetailsPanel.tsx +++ b/ui/v2.5/src/components/Performers/PerformerDetails/PerformerDetailsPanel.tsx @@ -100,11 +100,35 @@ export const PerformerDetailsPanel: React.FC = ({ ); } + function translateScrapedGender(gender?: string) { + if (!gender) { + return; + } + + let retEnum : GQL.GenderEnum | undefined; + + // try to translate from enum values first + const upperGender = gender?.toUpperCase(); + const asEnum = StashService.genderToString(upperGender as GQL.GenderEnum); + if (asEnum) { + retEnum = StashService.stringToGender(asEnum); + } else { + // try to match against gender strings + const caseInsensitive = true; + retEnum = StashService.stringToGender(gender, caseInsensitive); + } + + return StashService.genderToString(retEnum); + } + function updatePerformerEditStateFromScraper( state: Partial ) { updatePerformerEditState(state); + // gender is a string in the scraper data + setGender(translateScrapedGender(state.gender ?? undefined)); + // image is a base64 string // #404: don't overwrite image if it has been modified by the user if (image === undefined && (state as GQL.ScrapedPerformerDataFragment).image !== undefined) { diff --git a/ui/v2.5/src/core/StashService.ts b/ui/v2.5/src/core/StashService.ts index 6607795dc..9f8165758 100644 --- a/ui/v2.5/src/core/StashService.ts +++ b/ui/v2.5/src/core/StashService.ts @@ -717,12 +717,26 @@ export class StashService { } } - public static stringToGender(value?: string) { + public static stringToGender(value?: string, caseInsensitive?: boolean) { if (!value) { return undefined; } - return StashService.stringGenderMap.get(value); + const ret = StashService.stringGenderMap.get(value); + if (ret || !caseInsensitive) { + return ret; + } + + const asUpper = value.toUpperCase(); + const foundEntry = Array.from(StashService.stringGenderMap.entries()).find( + (e) => { + return e[0].toUpperCase() === asUpper; + } + ); + + if (foundEntry) { + return foundEntry[1]; + } } public static getGenderStrings() {