enum ScrapeType {
  "From text query"
  NAME
  "From existing object"
  FRAGMENT
  "From URL"
  URL
}

"Type of the content a scraper generates"
enum ScrapeContentType {
  GALLERY
  IMAGE
  MOVIE
  GROUP
  PERFORMER
  SCENE
}

"Scraped Content is the forming union over the different scrapers"
union ScrapedContent =
    ScrapedStudio
  | ScrapedTag
  | ScrapedScene
  | ScrapedGallery
  | ScrapedImage
  | ScrapedMovie
  | ScrapedGroup
  | ScrapedPerformer

type ScraperSpec {
  "URLs matching these can be scraped with"
  urls: [String!]
  supported_scrapes: [ScrapeType!]!
}

type Scraper {
  id: ID!
  name: String!
  "Details for performer scraper"
  performer: ScraperSpec
  "Details for scene scraper"
  scene: ScraperSpec
  "Details for gallery scraper"
  gallery: ScraperSpec
  "Details for image scraper"
  image: ScraperSpec
  "Details for movie scraper"
  movie: ScraperSpec @deprecated(reason: "use group")
  "Details for group scraper"
  group: ScraperSpec
}

type ScrapedStudio {
  "Set if studio matched"
  stored_id: ID
  name: String!
  url: String @deprecated(reason: "use urls")
  urls: [String!]
  parent: ScrapedStudio
  image: String
  details: String
  "Aliases must be comma-delimited to be parsed correctly"
  aliases: String
  tags: [ScrapedTag!]

  remote_site_id: String
}

type ScrapedTag {
  "Set if tag matched"
  stored_id: ID
  name: String!
  "Remote site ID, if applicable"
  remote_site_id: String
}

type ScrapedScene {
  title: String
  code: String
  details: String
  director: String
  url: String @deprecated(reason: "use urls")
  urls: [String!]
  date: String

  "This should be a base64 encoded data URL"
  image: String

  file: SceneFileType # Resolver
  studio: ScrapedStudio
  tags: [ScrapedTag!]
  performers: [ScrapedPerformer!]
  movies: [ScrapedMovie!] @deprecated(reason: "use groups")
  groups: [ScrapedGroup!]

  remote_site_id: String
  duration: Int
  fingerprints: [StashBoxFingerprint!]
}

input ScrapedSceneInput {
  title: String
  code: String
  details: String
  director: String
  url: String @deprecated(reason: "use urls")
  urls: [String!]
  date: String

  # no image, file, duration or relationships

  remote_site_id: String
}

type ScrapedGallery {
  title: String
  code: String
  details: String
  photographer: String
  url: String @deprecated(reason: "use urls")
  urls: [String!]
  date: String

  studio: ScrapedStudio
  tags: [ScrapedTag!]
  performers: [ScrapedPerformer!]
}

input ScrapedGalleryInput {
  title: String
  code: String
  details: String
  photographer: String
  url: String @deprecated(reason: "use urls")
  urls: [String!]
  date: String

  # no studio, tags or performers
}

type ScrapedImage {
  title: String
  code: String
  details: String
  photographer: String
  urls: [String!]
  date: String
  studio: ScrapedStudio
  tags: [ScrapedTag!]
  performers: [ScrapedPerformer!]
}

input ScrapedImageInput {
  title: String
  code: String
  details: String
  urls: [String!]
  date: String
}

input ScraperSourceInput {
  "Index of the configured stash-box instance to use. Should be unset if scraper_id is set"
  stash_box_index: Int @deprecated(reason: "use stash_box_endpoint")
  "Stash-box endpoint"
  stash_box_endpoint: String
  "Scraper ID to scrape with. Should be unset if stash_box_endpoint/stash_box_index is set"
  scraper_id: ID
}

type ScraperSource {
  "Index of the configured stash-box instance to use. Should be unset if scraper_id is set"
  stash_box_index: Int @deprecated(reason: "use stash_box_endpoint")
  "Stash-box endpoint"
  stash_box_endpoint: String
  "Scraper ID to scrape with. Should be unset if stash_box_endpoint/stash_box_index is set"
  scraper_id: ID
}

input ScrapeSingleSceneInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by scene fingerprints"
  scene_id: ID
  "Instructs to query by scene fragment"
  scene_input: ScrapedSceneInput
}

input ScrapeMultiScenesInput {
  "Instructs to query by scene fingerprints"
  scene_ids: [ID!]
}

input ScrapeSingleStudioInput {
  """
  Query can be either a name or a Stash ID
  """
  query: String
}

input ScrapeSingleTagInput {
  """
  Query can be either a name or a Stash ID
  """
  query: String
}

input ScrapeSinglePerformerInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by performer id"
  performer_id: ID
  "Instructs to query by performer fragment"
  performer_input: ScrapedPerformerInput
}

input ScrapeMultiPerformersInput {
  "Instructs to query by scene fingerprints"
  performer_ids: [ID!]
}

input ScrapeSingleGalleryInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by gallery id"
  gallery_id: ID
  "Instructs to query by gallery fragment"
  gallery_input: ScrapedGalleryInput
}

input ScrapeSingleImageInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by image id"
  image_id: ID
  "Instructs to query by image fragment"
  image_input: ScrapedImageInput
}

input ScrapeSingleMovieInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by movie id"
  movie_id: ID
  "Instructs to query by movie fragment"
  movie_input: ScrapedMovieInput
}

input ScrapeSingleGroupInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by group id"
  group_id: ID
  "Instructs to query by group fragment"
  group_input: ScrapedGroupInput
}

input StashBoxSceneQueryInput {
  "Index of the configured stash-box instance to use"
  stash_box_index: Int @deprecated(reason: "use stash_box_endpoint")
  "Endpoint of the stash-box instance to use"
  stash_box_endpoint: String
  "Instructs query by scene fingerprints"
  scene_ids: [ID!]
  "Query by query string"
  q: String
}

input StashBoxPerformerQueryInput {
  "Index of the configured stash-box instance to use"
  stash_box_index: Int @deprecated(reason: "use stash_box_endpoint")
  "Endpoint of the stash-box instance to use"
  stash_box_endpoint: String
  "Instructs query by scene fingerprints"
  performer_ids: [ID!]
  "Query by query string"
  q: String
}

type StashBoxPerformerQueryResult {
  query: String!
  results: [ScrapedPerformer!]!
}

type StashBoxFingerprint {
  algorithm: String!
  hash: String!
  duration: Int!
}

"""
Accepts either ids, or a combination of names and stash_ids.
If none are set, then all existing items will be tagged.
"""
input StashBoxBatchTagInput {
  "Stash endpoint to use for the tagging"
  endpoint: Int @deprecated(reason: "use stash_box_endpoint")
  "Endpoint of the stash-box instance to use"
  stash_box_endpoint: String
  "Fields to exclude when executing the tagging"
  exclude_fields: [String!]
  "Refresh items already tagged by StashBox if true. Only tag items with no StashBox tagging if false"
  refresh: Boolean!
  "If batch adding studios, should their parent studios also be created?"
  createParent: Boolean!
  """
  IDs in stash of the items to update.
  If set, names and stash_ids fields will be ignored.
  """
  ids: [ID!]
  "Names of the items in the stash-box instance to search for and create"
  names: [String!]
  "Stash IDs of the items in the stash-box instance to search for and create"
  stash_ids: [String!]
  "IDs in stash of the performers to update"
  performer_ids: [ID!] @deprecated(reason: "use ids")
  "Names of the performers in the stash-box instance to search for and create"
  performer_names: [String!] @deprecated(reason: "use names")
}
