add: simplified AMPP Script Task — looks up folder from Dragon-Wind, links asset (replaces folder-organizer)

This commit is contained in:
Zac Gaetano 2026-04-18 13:42:26 -04:00
parent b1d3b004ab
commit 9e5e13a593

58
folder-linker-v1.0.py Normal file
View file

@ -0,0 +1,58 @@
# ================================================================
# AMPP Framelight X — Dragon-Wind Folder Linker
# v1.0
#
# Replaces folder-organizer-v3.5.py.
#
# Dragon-Wind pre-creates all AMPP folder paths at upload time and
# stores the resulting folder:id. This script simply looks up that
# folder:id by filename and links the freshly-ingested asset to it.
#
# Result: zero folder creation logic here — no prefix parsing,
# no hierarchy walks, no duplicate-folder edge cases.
#
# Requirements:
# - WILD_DRAGON_API must be reachable from the AMPP node.
# - Asset must have been uploaded through Dragon-Wind (if not,
# the 404 path is handled gracefully — asset is skipped).
#
# Configuration:
# Set WILD_DRAGON_API to your Dragon-Wind MAM API base URL.
# ================================================================
import json
import urllib.parse
WILD_DRAGON_API = "https://wild-dragon.wilddragon.net" # update if needed
asset_id = str(asset.Id)
asset_name = str(job.AssetName)
try:
encoded_name = urllib.parse.quote(asset_name, safe="")
resp = httpClient.sendAsync(
"GET",
WILD_DRAGON_API + "/api/v1/ampp/folder-for/" + encoded_name
)
if not isinstance(resp, dict):
raise ValueError("Unexpected response type from Dragon-Wind: " + str(type(resp)))
folder_id = str(resp.get("folder_id", "")).strip()
if not folder_id:
# Asset was not uploaded through Dragon-Wind — skip gracefully.
# To handle legacy assets still using filename prefixes, you can
# re-enable folder-organizer-v3.5.py here as a fallback.
pass
else:
link_body = json.dumps(
{"folder:id": folder_id, "asset:id": asset_id},
separators=(',', ':')
)
httpClient.sendAsync("POST", "api/v1/store/folder/references", link_body)
except Exception as ex:
raise Exception(
"Dragon-Wind folder link failed for '" + asset_name + "': " + str(ex)
)