Studio Operations¶
Operations for managing studios (production companies).
Bases: StashClientProtocol
Mixin for studio-related client methods.
Functions¶
find_studio
async
¶
find_studio(id: str) -> Studio | None
Find a studio by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the studio to find |
required |
Returns:
| Type | Description |
|---|---|
Studio | None
|
Studio object if found, None otherwise |
find_studios
async
¶
find_studios(
filter_: dict[str, Any] | None = None,
studio_filter: dict[str, Any] | None = None,
q: str | None = None,
) -> FindStudiosResultType
Find studios matching the given filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_
|
dict[str, Any] | None
|
Optional general filter parameters: - q: str (search query) - direction: SortDirectionEnum (ASC/DESC) - page: int - per_page: int - sort: str (field to sort by) |
None
|
studio_filter
|
dict[str, Any] | None
|
Optional studio-specific filter |
None
|
q
|
str | None
|
Optional search query (alternative to filter_["q"]) |
None
|
Returns:
| Type | Description |
|---|---|
FindStudiosResultType
|
FindStudiosResultType containing: - count: Total number of matching studios - studios: List of Studio objects |
create_studio
async
¶
Create a new studio in Stash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
studio
|
Studio
|
Studio object with the data to create. Required fields: - name: Studio name |
required |
Returns:
| Type | Description |
|---|---|
Studio
|
Created Studio object with ID and any server-generated fields |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the studio data is invalid |
TransportError
|
If the request fails |
update_studio
async
¶
Update an existing studio in Stash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
studio
|
Studio
|
Studio object with updated data. Required fields: - id: Studio ID to update Any other fields that are set will be updated. Fields that are None will be ignored. |
required |
Returns:
| Type | Description |
|---|---|
Studio
|
Updated Studio object with any server-generated fields |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the studio data is invalid |
TransportError
|
If the request fails |
studio_destroy
async
¶
Delete a studio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
StudioDestroyInput | dict[str, Any]
|
StudioDestroyInput object or dictionary containing: - id: Studio ID to delete (required) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the studio was successfully deleted |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the studio ID is invalid |
TransportError
|
If the request fails |
studios_destroy
async
¶
Delete multiple studios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
List of studio IDs to delete |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the studios were successfully deleted |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any studio ID is invalid |
TransportError
|
If the request fails |
bulk_studio_update
async
¶
bulk_studio_update(
input_data: BulkStudioUpdateInput | dict[str, Any],
) -> list[Studio]
Bulk update studios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BulkStudioUpdateInput | dict[str, Any]
|
BulkStudioUpdateInput object or dictionary containing: - ids: List of studio IDs to update (optional) - And any fields to update (e.g., url, rating100, etc.) |
required |
Returns:
| Type | Description |
|---|---|
list[Studio]
|
List of updated Studio objects |
Examples:
Update multiple studios' ratings:
Add tags to multiple studios:
find_studio_hierarchy
async
¶
find_studio_hierarchy(studio_id: str) -> list[Studio]
Get full parent chain from root to this studio.
Recursively traverses the parent_studio relationship to build a complete hierarchy from the root studio down to the specified studio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
studio_id
|
str
|
The ID of the studio to get hierarchy for |
required |
Returns:
| Type | Description |
|---|---|
list[Studio]
|
List of Studio objects ordered from root (index 0) to the specified |
list[Studio]
|
studio (last index). Returns empty list if studio not found. |
Examples:
Get studio hierarchy:
# Studio structure: Root > Parent > Child
hierarchy = await client.find_studio_hierarchy("child_id")
# Returns: [<Root Studio>, <Parent Studio>, <Child Studio>]
for i, studio in enumerate(hierarchy):
print(f"Level {i}: {studio.name}")
Check if studio has parents:
find_studio_root
async
¶
find_studio_root(studio_id: str) -> Studio | None
Find the top-level parent studio.
Traverses the parent chain to find the root studio (the one with no parent).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
studio_id
|
str
|
The ID of the studio to find root for |
required |
Returns:
| Type | Description |
|---|---|
Studio | None
|
Root Studio object, or None if studio not found |
Examples:
Get root studio:
Compare studio with its root:
map_studio_ids
async
¶
map_studio_ids(
studios: list[str | dict[str, Any] | Studio],
create: bool = False,
) -> list[str]
Convert studio names/objects to IDs, optionally creating missing studios.
This is a convenience method to resolve studio references to their IDs, reducing boilerplate when working with studio relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
studios
|
list[str | dict[str, Any] | Studio]
|
List of studio references, can be: - str: Studio name (searches for exact match) - dict: Studio filter criteria (e.g., {"name": "Acme Studios"}) - Studio: Studio object (extracts ID if present, otherwise searches by name) |
required |
create
|
bool
|
If True, create studios that don't exist. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of studio IDs. Skips studios that aren't found (unless create=True). |
Examples:
Map studio names to IDs:
studio_ids = await client.map_studio_ids(["Acme", "Foo Studios", "Bar Inc"])
# Returns: ["1", "2", "3"] (IDs of existing studios)
Auto-create missing studios:
studio_ids = await client.map_studio_ids(
["Acme", "NewStudio"],
create=True
)
# Creates "NewStudio" if it doesn't exist
Mix of strings and Studio objects:
studio_obj = Studio(name="Acme")
studio_ids = await client.map_studio_ids([studio_obj, "Foo Studios"])
Use in scene creation: