@danhachuel/thunderbolt 0.5.39 → 0.5.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -94,6 +94,29 @@ def _model(card: Mapping[str, Any]) -> str:
|
|
|
94
94
|
return str(card.get("model") or "").strip()
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def _hydrate_media_card(settings: Mapping[str, Any], card: Mapping[str, Any]) -> dict[str, Any]:
|
|
98
|
+
"""Restore credentials when a persisted thumbnail task contains an old card snapshot."""
|
|
99
|
+
effective = dict(card)
|
|
100
|
+
if str(effective.get("api_key") or "").strip():
|
|
101
|
+
return effective
|
|
102
|
+
card_id = str(effective.get("id") or "").strip()
|
|
103
|
+
stored_cards = settings.get("media_provider_cards")
|
|
104
|
+
if isinstance(stored_cards, list):
|
|
105
|
+
for stored in stored_cards:
|
|
106
|
+
if isinstance(stored, Mapping) and card_id and str(stored.get("id") or "").strip() == card_id:
|
|
107
|
+
key = str(stored.get("api_key") or stored.get("key") or "").strip()
|
|
108
|
+
if key:
|
|
109
|
+
effective["api_key"] = key
|
|
110
|
+
break
|
|
111
|
+
if not str(effective.get("api_key") or "").strip() and str(effective.get("provider") or "").strip().lower() == "agnes":
|
|
112
|
+
for key_name in ("agnes_api_key", "agnes_ai_api_key", "agnes_token", "media_agnes_api_key"):
|
|
113
|
+
key = str(settings.get(key_name) or "").strip()
|
|
114
|
+
if key:
|
|
115
|
+
effective["api_key"] = key
|
|
116
|
+
break
|
|
117
|
+
return effective
|
|
118
|
+
|
|
119
|
+
|
|
97
120
|
def _base_url(card: Mapping[str, Any]) -> str:
|
|
98
121
|
return str(card.get("base_url") or "").strip().rstrip("/")
|
|
99
122
|
|
|
@@ -363,7 +386,7 @@ def generate_image_for_card(
|
|
|
363
386
|
thumbnail_blueprint: Mapping[str, Any] | None = None,
|
|
364
387
|
) -> Path:
|
|
365
388
|
"""Generate one image with the selected media card."""
|
|
366
|
-
card =
|
|
389
|
+
card = _hydrate_media_card(settings, card)
|
|
367
390
|
provider = str(card.get("provider") or "").strip().lower()
|
|
368
391
|
if provider == "canva":
|
|
369
392
|
ensure_storage()
|
package/package.json
CHANGED