mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Include gender in performer scraper results (#448)
* Fix scraper gender * Set scraped gender in the UI * Match gender on enum or case insensitive string
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
fragment ScrapedPerformerData on ScrapedPerformer {
|
fragment ScrapedPerformerData on ScrapedPerformer {
|
||||||
name
|
name
|
||||||
|
gender
|
||||||
url
|
url
|
||||||
twitter
|
twitter
|
||||||
instagram
|
instagram
|
||||||
@@ -20,6 +21,7 @@ fragment ScrapedPerformerData on ScrapedPerformer {
|
|||||||
fragment ScrapedScenePerformerData on ScrapedScenePerformer {
|
fragment ScrapedScenePerformerData on ScrapedScenePerformer {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
gender
|
||||||
url
|
url
|
||||||
twitter
|
twitter
|
||||||
instagram
|
instagram
|
||||||
@@ -45,7 +47,6 @@ fragment ScrapedMovieData on ScrapedMovie {
|
|||||||
director
|
director
|
||||||
url
|
url
|
||||||
synopsis
|
synopsis
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment ScrapedSceneMovieData on ScrapedSceneMovie {
|
fragment ScrapedSceneMovieData on ScrapedSceneMovie {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"""A performer from a scraping operation..."""
|
"""A performer from a scraping operation..."""
|
||||||
type ScrapedPerformer {
|
type ScrapedPerformer {
|
||||||
name: String
|
name: String
|
||||||
|
gender: String
|
||||||
url: String
|
url: String
|
||||||
twitter: String
|
twitter: String
|
||||||
instagram: String
|
instagram: String
|
||||||
@@ -22,6 +23,7 @@ type ScrapedPerformer {
|
|||||||
|
|
||||||
input ScrapedPerformerInput {
|
input ScrapedPerformerInput {
|
||||||
name: String
|
name: String
|
||||||
|
gender: String
|
||||||
url: String
|
url: String
|
||||||
twitter: String
|
twitter: String
|
||||||
instagram: String
|
instagram: String
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type ScrapedScenePerformer {
|
|||||||
"""Set if performer matched"""
|
"""Set if performer matched"""
|
||||||
id: ID
|
id: ID
|
||||||
name: String!
|
name: String!
|
||||||
|
gender: String
|
||||||
url: String
|
url: String
|
||||||
twitter: String
|
twitter: String
|
||||||
instagram: String
|
instagram: String
|
||||||
@@ -54,7 +55,6 @@ type ScrapedSceneMovie {
|
|||||||
director: String
|
director: String
|
||||||
synopsis: String
|
synopsis: String
|
||||||
url: String
|
url: String
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScrapedSceneStudio {
|
type ScrapedSceneStudio {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type ScrapedItem struct {
|
|||||||
|
|
||||||
type ScrapedPerformer struct {
|
type ScrapedPerformer struct {
|
||||||
Name *string `graphql:"name" json:"name"`
|
Name *string `graphql:"name" json:"name"`
|
||||||
|
Gender *string `graphql:"gender" json:"gender"`
|
||||||
URL *string `graphql:"url" json:"url"`
|
URL *string `graphql:"url" json:"url"`
|
||||||
Twitter *string `graphql:"twitter" json:"twitter"`
|
Twitter *string `graphql:"twitter" json:"twitter"`
|
||||||
Instagram *string `graphql:"instagram" json:"instagram"`
|
Instagram *string `graphql:"instagram" json:"instagram"`
|
||||||
@@ -45,6 +46,7 @@ type ScrapedPerformer struct {
|
|||||||
// this type has no Image field
|
// this type has no Image field
|
||||||
type ScrapedPerformerStash struct {
|
type ScrapedPerformerStash struct {
|
||||||
Name *string `graphql:"name" json:"name"`
|
Name *string `graphql:"name" json:"name"`
|
||||||
|
Gender *string `graphql:"gender" json:"gender"`
|
||||||
URL *string `graphql:"url" json:"url"`
|
URL *string `graphql:"url" json:"url"`
|
||||||
Twitter *string `graphql:"twitter" json:"twitter"`
|
Twitter *string `graphql:"twitter" json:"twitter"`
|
||||||
Instagram *string `graphql:"instagram" json:"instagram"`
|
Instagram *string `graphql:"instagram" json:"instagram"`
|
||||||
@@ -91,6 +93,7 @@ type ScrapedScenePerformer struct {
|
|||||||
// Set if performer matched
|
// Set if performer matched
|
||||||
ID *string `graphql:"id" json:"id"`
|
ID *string `graphql:"id" json:"id"`
|
||||||
Name string `graphql:"name" json:"name"`
|
Name string `graphql:"name" json:"name"`
|
||||||
|
Gender *string `graphql:"gender" json:"gender"`
|
||||||
URL *string `graphql:"url" json:"url"`
|
URL *string `graphql:"url" json:"url"`
|
||||||
Twitter *string `graphql:"twitter" json:"twitter"`
|
Twitter *string `graphql:"twitter" json:"twitter"`
|
||||||
Instagram *string `graphql:"instagram" json:"instagram"`
|
Instagram *string `graphql:"instagram" json:"instagram"`
|
||||||
@@ -116,15 +119,15 @@ type ScrapedSceneStudio struct {
|
|||||||
|
|
||||||
type ScrapedSceneMovie struct {
|
type ScrapedSceneMovie struct {
|
||||||
// Set if movie matched
|
// Set if movie matched
|
||||||
ID *string `graphql:"id" json:"id"`
|
ID *string `graphql:"id" json:"id"`
|
||||||
Name string `graphql:"name" json:"name"`
|
Name string `graphql:"name" json:"name"`
|
||||||
Aliases string `graphql:"aliases" json:"aliases"`
|
Aliases string `graphql:"aliases" json:"aliases"`
|
||||||
Duration string `graphql:"duration" json:"duration"`
|
Duration string `graphql:"duration" json:"duration"`
|
||||||
Date string `graphql:"date" json:"date"`
|
Date string `graphql:"date" json:"date"`
|
||||||
Rating string `graphql:"rating" json:"rating"`
|
Rating string `graphql:"rating" json:"rating"`
|
||||||
Director string `graphql:"director" json:"director"`
|
Director string `graphql:"director" json:"director"`
|
||||||
Synopsis string `graphql:"synopsis" json:"synopsis"`
|
Synopsis string `graphql:"synopsis" json:"synopsis"`
|
||||||
URL *string `graphql:"url" json:"url"`
|
URL *string `graphql:"url" json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScrapedSceneTag struct {
|
type ScrapedSceneTag struct {
|
||||||
|
|||||||
@@ -100,11 +100,35 @@ export const PerformerDetailsPanel: React.FC<IPerformerDetails> = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
function updatePerformerEditStateFromScraper(
|
||||||
state: Partial<GQL.ScrapedPerformerDataFragment>
|
state: Partial<GQL.ScrapedPerformerDataFragment>
|
||||||
) {
|
) {
|
||||||
updatePerformerEditState(state);
|
updatePerformerEditState(state);
|
||||||
|
|
||||||
|
// gender is a string in the scraper data
|
||||||
|
setGender(translateScrapedGender(state.gender ?? undefined));
|
||||||
|
|
||||||
// image is a base64 string
|
// image is a base64 string
|
||||||
// #404: don't overwrite image if it has been modified by the user
|
// #404: don't overwrite image if it has been modified by the user
|
||||||
if (image === undefined && (state as GQL.ScrapedPerformerDataFragment).image !== undefined) {
|
if (image === undefined && (state as GQL.ScrapedPerformerDataFragment).image !== undefined) {
|
||||||
|
|||||||
@@ -717,12 +717,26 @@ export class StashService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static stringToGender(value?: string) {
|
public static stringToGender(value?: string, caseInsensitive?: boolean) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return undefined;
|
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() {
|
public static getGenderStrings() {
|
||||||
|
|||||||
Reference in New Issue
Block a user