Add POST /api/wishlist/process endpoint for external API access

Allows external apps to trigger wishlist processing without needing
to look up automation IDs. Returns 409 if already running. Uses the
same _process_wishlist_automatically function as the automation engine.
This commit is contained in:
Broque Thomas 2026-03-27 11:58:22 -07:00
parent 7f9755a26e
commit 72fab16bad

View file

@ -20239,6 +20239,22 @@ def get_database_stats():
print(f"Error getting database stats: {e}")
return jsonify({"error": str(e)}), 500
@app.route('/api/wishlist/process', methods=['POST'])
def process_wishlist_api():
"""Trigger wishlist processing via API. Processes pending wishlist tracks in the background."""
try:
if wishlist_auto_processing:
return jsonify({"success": False, "error": "Wishlist processing already in progress"}), 409
# Run in background thread (same as automation trigger)
import threading
thread = threading.Thread(target=_process_wishlist_automatically, daemon=True)
thread.start()
return jsonify({"success": True, "message": "Wishlist processing started"})
except Exception as e:
return jsonify({"success": False, "error": str(e)}), 500
@app.route('/api/wishlist/count', methods=['GET'])
def get_wishlist_count():
"""Endpoint to get current wishlist count."""