@danhachuel/thunderbolt 0.3.90 → 0.3.91

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.
package/app/main.py CHANGED
@@ -5066,6 +5066,22 @@ def render_google_accounts():
5066
5066
  key=f"batch_session_info_{account_id}",
5067
5067
  help="Token sessionInfo usado pelo Upload directo. É guardado por conta e sincronizado no credentials.json; os cookies e restantes valores continuam exclusivamente no documento.",
5068
5068
  )
5069
+ captured_at_value = str(
5070
+ session_health.captured_at
5071
+ or batch_account.get("sessionInfoCapturedAt")
5072
+ or batch_account.get("session_info_captured_at")
5073
+ or ""
5074
+ ).strip()
5075
+ try:
5076
+ account_session_info_captured_at = datetime.fromisoformat(captured_at_value.replace("Z", "+00:00")).date() if captured_at_value else None
5077
+ except ValueError:
5078
+ account_session_info_captured_at = None
5079
+ account_session_info_captured_at = st.date_input(
5080
+ "Data de Captura",
5081
+ value=account_session_info_captured_at,
5082
+ key=f"batch_session_info_captured_at_{account_id}",
5083
+ help="Data em que o sessionInfo token foi capturado. É usada para calcular o alerta de expiração e não revela o token.",
5084
+ )
5069
5085
  save_account = st.form_submit_button("Guardar dados da conta Google", type="primary", use_container_width=True)
5070
5086
 
5071
5087
  st.markdown("**Documento de cookies/credenciais desta conta Google**")
@@ -5119,8 +5135,14 @@ def render_google_accounts():
5119
5135
  credentials_changed = any(existing.get(field, "") != value for field, value in (("email", account_email.strip()), ("client_id", account_client_id.strip()), ("client_secret", account_client_secret.strip())))
5120
5136
  if credentials_changed:
5121
5137
  delete_youtube_batch_token(existing, STORAGE)
5122
- existing.update({"label": account_label.strip() or "Canais YouTube", "email": account_email.strip(), "client_id": account_client_id.strip(), "client_secret": account_client_secret.strip(), "sessionInfo": account_session_info.strip()})
5123
- update_credentials_document_session_info(STORAGE, existing, account_session_info.strip())
5138
+ captured_at_iso = account_session_info_captured_at.isoformat() if isinstance(account_session_info_captured_at, date) else ""
5139
+ existing.update({"label": account_label.strip() or "Canais YouTube", "email": account_email.strip(), "client_id": account_client_id.strip(), "client_secret": account_client_secret.strip(), "sessionInfo": account_session_info.strip(), "sessionInfoCapturedAt": captured_at_iso})
5140
+ update_credentials_document_session_info(
5141
+ STORAGE,
5142
+ existing,
5143
+ account_session_info.strip(),
5144
+ captured_at=captured_at_iso,
5145
+ )
5124
5146
  ensure_credentials_document(STORAGE, existing, settings, channel_state)
5125
5147
  settings["youtube_batch_accounts"] = batch_accounts
5126
5148
  write_json("settings.json", settings)
@@ -242,8 +242,14 @@ def save_credentials_document(storage_root: Path, account: dict[str, Any], docum
242
242
  return destination
243
243
 
244
244
 
245
- def update_credentials_document_session_info(storage_root: Path, account: dict[str, Any], session_info: str) -> Path | None:
246
- """Save sessionInfo and its UTC capture time without exposing the token."""
245
+ def update_credentials_document_session_info(
246
+ storage_root: Path,
247
+ account: dict[str, Any],
248
+ session_info: str,
249
+ *,
250
+ captured_at: str | None = None,
251
+ ) -> Path | None:
252
+ """Save sessionInfo and an optional user-confirmed capture date without exposing the token."""
247
253
  path = credentials_document_path(storage_root, account)
248
254
  if path.exists():
249
255
  raw = _read_json_document(path) or {}
@@ -251,7 +257,12 @@ def update_credentials_document_session_info(storage_root: Path, account: dict[s
251
257
  raw = load_credentials_document(storage_root, {**account, "sessionInfo": session_info}, create=True)
252
258
  document = _normalise_document(raw, {**account, "sessionInfo": session_info})
253
259
  document["sessionInfo"] = str(session_info or "").strip()
254
- document["sessionInfoCapturedAt"] = _session_info_now() if document["sessionInfo"] else ""
260
+ if not document["sessionInfo"]:
261
+ document["sessionInfoCapturedAt"] = ""
262
+ elif captured_at is None:
263
+ document["sessionInfoCapturedAt"] = _session_info_now()
264
+ else:
265
+ document["sessionInfoCapturedAt"] = str(captured_at).strip()
255
266
  return save_credentials_document(storage_root, account, document)
256
267
 
257
268
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.3.90",
3
+ "version": "0.3.91",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",