Is your feature request related to a problem? Please describe.
When automatically identifying a scene fails, I often struggle to identify the specific scene when I only know the studio or performer and duration.
Describe the solution you'd like
I would like to be able to batch import scene metadata from stash-box into stash, specifically for a given studio or performer. This would allow me to easily sort and filter scenes by duration, making it simpler to identify the scene I'm looking for.
Describe alternatives you've considered
I have considered manually searching for each scene individually, but this is time-consuming and inefficient.
Additional context
This feature would significantly enhance my workflow by providing a more efficient way to manage and identify scenes in stash.
Here is a sample script to get all scenes given a studio id. Now I have to add all these scenes to stash with the given studio id.
This works
title = "Example scene"
studio_id = 18
variables = { "input": { "title": title, "studio_id": studio_id } }
query = """
mutation SceneCreate($input: SceneCreateInput!) {
sceneCreate(input: $input) {
id
}
}
"""
requests.post("http://localhost:9999/graphql", json={"query": query, "variables": variables})
but if I add duration to the query I get the error
Error creating scene: 422 - {"errors":[{"message":"unknown field","path":["variable","input","duration"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}
Here is the script I have so far:
import requests
# GraphQL endpoint URL
STASHBOX_GRAPHQL_ENDPOINT = "https://stashdb.org/graphql"
STASH_GRAPHQL_ENDPOINT = "http://localhost:9999/graphql"
STASHBOX_API_KEY = "your-stash-box-api-key"
def execute_graphql_query(query, variables=None):
headers = {
"Content-Type": "application/json",
"ApiKey": STASHBOX_API_KEY
}
payload = {"query": query}
if variables:
payload["variables"] = variables
response = requests.post(STASHBOX_GRAPHQL_ENDPOINT, json=payload, headers=headers)
response.raise_for_status()
return response.json()["data"]
def get_studio_scenes(studio_id):
query = """
query Scenes($input: SceneQueryInput!) {
queryScenes(input: $input) {
count
scenes {
id
release_date
title
duration
}
__typename
}
}
"""
variables = {
"input": {
"direction": "DESC",
"page": 1,
"parentStudio": studio_id,
"per_page": 20,
"sort": "DATE"
}
}
result = execute_graphql_query(query, variables)
scenes = result["queryScenes"]["scenes"]
total_scenes = result["queryScenes"]["count"]
# Yield the initial set of scenes
for scene in scenes:
yield scene
# Fetch and yield remaining pages
page = 2
while len(scenes) < total_scenes:
variables["input"]["page"] = page
result = execute_graphql_query(query, variables)
scenes = result["queryScenes"]["scenes"]
for scene in scenes:
yield scene
page += 1
def add_scene(title, duration, studio_id):
query = """
mutation SceneCreate($input: SceneCreateInput!) {
sceneCreate(input: $input) {
id
}
}
"""
variables = {
"input": {
"title": title,
"duration": duration,
"studio_id": studio_id
}
}
response = requests.post(STASH_GRAPHQL_ENDPOINT, json={"query": query, "variables": variables})
if response.status_code == 200:
data = response.json()
if "errors" in data:
print(f"Error creating scene: {data['errors']}")
else:
scene_id = data["data"]["sceneCreate"]["id"]
print(f"Scene '{title}' created successfully with ID: {scene_id}")
else:
print(f"Error creating scene: {response.status_code} - {response.text}")
studio_id = "sample_studio_id"
for scene in get_studio_scenes(studio_id):
print(f"Scene ID: {scene['id']}, Title: {scene['title']}, Release Date: {scene['release_date']}, Duration: {scene['duration']}")
add_scene(scene['title'], scene['duration'], studio_id)
Is your feature request related to a problem? Please describe.
When automatically identifying a scene fails, I often struggle to identify the specific scene when I only know the studio or performer and duration.
Describe the solution you'd like
I would like to be able to batch import scene metadata from stash-box into stash, specifically for a given studio or performer. This would allow me to easily sort and filter scenes by duration, making it simpler to identify the scene I'm looking for.
Describe alternatives you've considered
I have considered manually searching for each scene individually, but this is time-consuming and inefficient.
Additional context
This feature would significantly enhance my workflow by providing a more efficient way to manage and identify scenes in stash.
Here is a sample script to get all scenes given a studio id. Now I have to add all these scenes to stash with the given studio id.
This works
but if I add duration to the query I get the error
Here is the script I have so far: