Add prefix stripper v3.2
This commit is contained in:
parent
70e4bced30
commit
c7a6a338df
1 changed files with 37 additions and 0 deletions
37
prefix-stripper-v3.2.py
Normal file
37
prefix-stripper-v3.2.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# ================================================================
|
||||
# AMPP Framelight X — Nested Prefix Stripper
|
||||
# Production v3.2 — Delimiter: --
|
||||
#
|
||||
# Removes the folder prefix from asset names after organization.
|
||||
#
|
||||
# Examples:
|
||||
# "BMG--Videos--File.mp4" → "File.mp4"
|
||||
# "NEWS--PKG--Clip1.mxf" → "Clip1.mxf"
|
||||
# "IMG--4709.jpg" → "4709.jpg"
|
||||
# "No-Delimiter.mp4" → "No-Delimiter.mp4" (unchanged)
|
||||
# ================================================================
|
||||
import json
|
||||
|
||||
PREFIX_DELIM = "--"
|
||||
asset_id = str(asset.Id)
|
||||
asset_name = str(job.AssetName)
|
||||
|
||||
if PREFIX_DELIM in asset_name:
|
||||
parts = asset_name.split(PREFIX_DELIM)
|
||||
if len(parts) >= 2:
|
||||
# The last part is the filename; everything before is the prefix
|
||||
filename = parts[-1]
|
||||
|
||||
# Update asset metadata with the stripped name
|
||||
try:
|
||||
# Use the AMPP asset metadata update endpoint
|
||||
update_body = json.dumps({"name:text": filename})
|
||||
httpClient.sendAsync(
|
||||
"PATCH",
|
||||
"api/v1/store/assets/" + asset_id,
|
||||
update_body
|
||||
)
|
||||
except:
|
||||
# If PATCH fails (older platform versions), the asset keeps its original name
|
||||
# but the folder organization has already succeeded
|
||||
pass
|
||||
Loading…
Reference in a new issue