stashapp / stash

An organizer for your porn, written in Go. Documentation: https://docs.stashapp.cc
https://stashapp.cc/
GNU Affero General Public License v3.0
8.44k stars 749 forks source link

Upload Videos/Images from the GraphQL API #4995

Open DefaultLP opened 1 week ago

DefaultLP commented 1 week ago

Is your feature request related to a problem? Please describe. I am currently in the process of writing a browser extension that allows me to upload & tag files directly from specific websites, without having to open the stash web UI. The problem (or more the inconvenience) is that uploading & tagging a video/image involves multiple steps that could be combined into one GraphQL function.

The steps to this process are:

  1. Upload the file to the server
  2. Tell stash to perform a metadata scan
  3. Retrieve the newly added file IDs
  4. Update said files with tags and other metadata

All in all very much doable, but in my humble opinion, this could also be just one function. Steps 2-4 are just a roundabout way of adding the missing metadata to the uploaded file.


Describe the solution you'd like Mutation functions "CreateVideo" and "CreateImage". The inputs could be the same as the "*UpdateInput" parameter, but obviously without the ID and with additional path & filename parameters.

A question would be what to upload. A URL? A base64 string? Or even a binary format. I don't really know what would fit best here. For images, this would be easy since it is kind of already possible for tags. Here a URL or base64 string can be used. But video files would be more complicated.

Very quick mockup:

input ImageCreateInput {
  image_url: String! # or base64
  path: String!
  file_name: String!
  title: String
  code: String
  # rating expressed as 1-100
  rating100: Int
  organized: Boolean
  date: String
  details: String
  photographer: String

  studio_id: ID
  performer_ids: [ID!]
  tag_ids: [ID!]
  gallery_ids: [ID!]

  primary_file_id: ID
}

mutation CreateImage($input: ImageCreateInput!) {
  imageCreate(input: $input) {
    ...SlimImageData
  }
}

I don't know the intricacies of the Go backend (because I don't know GO at all), but from my understanding, this should be possible, if unconventional. Stash already has functions to create everything that does not require changing the filesystem as well as functions for deleting files from the filesystem.


Describe alternatives you've considered Well, I don't know of any other solutions. This is more of a do or don't kind of request.


Additional context The main reason I requested it is for convenience. It is absolutely possible without these functions, just way more of a hassle.