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

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

"Scraped Content is the forming union over the different scrapers"
union ScrapedContent =
    ScrapedStudio
  | ScrapedTag
  | ScrapedScene
  | ScrapedGallery
  | ScrapedMovie
  | 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 movie scraper"
  movie: ScraperSpec
}

type ScrapedStudio {
  "Set if studio matched"
  stored_id: ID
  name: String!
  url: String
  parent: ScrapedStudio
  image: String

  remote_site_id: String
}

type ScrapedTag {
  "Set if tag matched"
  stored_id: ID
  name: 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!]

  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
}

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_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_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 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 ScrapeSingleMovieInput {
  "Instructs to query by string"
  query: String
  "Instructs to query by movie id"
  movie_id: ID
  "Instructs to query by gallery fragment"
  movie_input: ScrapedMovieInput
}

input StashBoxSceneQueryInput {
  "Index of the configured stash-box instance to use"
  stash_box_index: Int!
  "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!
  "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!
}

"If neither ids nor names are set, tag all items"
input StashBoxBatchTagInput {
  "Stash endpoint to use for the tagging"
  endpoint: Int!
  "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!
  "If set, only tag these ids"
  ids: [ID!]
  "If set, only tag these names"
  names: [String!]
  "If set, only tag these performer ids"
  performer_ids: [ID!] @deprecated(reason: "use ids")
  "If set, only tag these performer names"
  performer_names: [String!] @deprecated(reason: "use names")
}
