@danhachuel/thunderbolt 0.5.93 → 0.5.94
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 +11 -15
- package/integrations/youtube_growth_api.py +2 -2
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -124,6 +124,7 @@ from integrations.youtube_direct_credentials import delete_credentials_document,
|
|
|
124
124
|
from integrations.session_info_health import check_account_session_info_health
|
|
125
125
|
from integrations.youtube_session_manager import renew_account_session
|
|
126
126
|
from integrations.youtube_batch import account_key as youtube_batch_account_key, account_status as youtube_batch_account_status, authorize_account as authorize_youtube_batch_account, delete_account_token as delete_youtube_batch_token, list_my_channels as list_youtube_batch_channels, loopback_redirect_uri
|
|
127
|
+
from integrations.youtube_growth_api import find_account_for_channel as find_youtube_growth_account
|
|
127
128
|
from integrations.local_runtime import MoneyPrinterRuntime
|
|
128
129
|
from integrations.moneyprinter_config import sync_moneyprinter_config
|
|
129
130
|
from integrations.openai_model_discovery import DEFAULT_NVIDIA_NIM_BASE_URL
|
|
@@ -1496,21 +1497,6 @@ def render_growth_youtube():
|
|
|
1496
1497
|
st.caption("Auditoria pública baseada nos 3 pilares críticos e nas métricas secundárias do agente Growth.")
|
|
1497
1498
|
growth_settings = read_json("settings.json", {})
|
|
1498
1499
|
youtube_data_api_ready = bool(str(growth_settings.get("youtube_api_key") or os.getenv("YOUTUBE_API_KEY") or "").strip())
|
|
1499
|
-
growth_accounts = growth_settings.get("youtube_batch_accounts", [])
|
|
1500
|
-
analytics_accounts_ready = False
|
|
1501
|
-
if isinstance(growth_accounts, list):
|
|
1502
|
-
for growth_account in growth_accounts:
|
|
1503
|
-
if isinstance(growth_account, dict) and youtube_batch_account_status(growth_account, STORAGE).ok:
|
|
1504
|
-
analytics_accounts_ready = True
|
|
1505
|
-
break
|
|
1506
|
-
st.markdown("**Estado das APIs de Growth**")
|
|
1507
|
-
api_status_cols = st.columns(2, gap="small")
|
|
1508
|
-
with api_status_cols[0]:
|
|
1509
|
-
st.caption("YouTube Data API v3: Metadados públicos")
|
|
1510
|
-
_api_status_badge("Configured" if youtube_data_api_ready else "Missing configuration", "ready" if youtube_data_api_ready else "missing")
|
|
1511
|
-
with api_status_cols[1]:
|
|
1512
|
-
st.caption("YouTube Analytics API: Métricas internas")
|
|
1513
|
-
_api_status_badge("Configured" if analytics_accounts_ready else "Missing configuration", "ready" if analytics_accounts_ready else "missing")
|
|
1514
1500
|
channels = [item for item in read_json("channels.json", []) if isinstance(item, dict) and item.get("active", True) and is_youtube_channel_record(item)]
|
|
1515
1501
|
if not channels:
|
|
1516
1502
|
st.info("Cadastre pelo menos um canal YouTube em Canais YouTube para iniciar a análise.")
|
|
@@ -1526,6 +1512,16 @@ def render_growth_youtube():
|
|
|
1526
1512
|
with action_status_col:
|
|
1527
1513
|
if st.session_state.get("growth_analysis_status") == "complete":
|
|
1528
1514
|
st.markdown('<div style="padding-top:9px;color:#22c55e;font-weight:700;white-space:nowrap;">✓ Análise concluída</div>', unsafe_allow_html=True)
|
|
1515
|
+
matched_growth_account = find_youtube_growth_account(selected, growth_settings)
|
|
1516
|
+
analytics_accounts_ready = bool(matched_growth_account and youtube_batch_account_status(matched_growth_account, STORAGE).ok)
|
|
1517
|
+
st.markdown("**Estado das APIs de Growth**")
|
|
1518
|
+
api_status_cols = st.columns(2, gap="small")
|
|
1519
|
+
with api_status_cols[0]:
|
|
1520
|
+
st.caption("YouTube Data API v3: Metadados públicos")
|
|
1521
|
+
_api_status_badge("Configured" if youtube_data_api_ready else "Missing configuration", "ready" if youtube_data_api_ready else "missing")
|
|
1522
|
+
with api_status_cols[1]:
|
|
1523
|
+
st.caption("YouTube Analytics API: Métricas internas")
|
|
1524
|
+
_api_status_badge("Configured" if analytics_accounts_ready else "Missing configuration", "ready" if analytics_accounts_ready else "missing")
|
|
1529
1525
|
if analyse_clicked:
|
|
1530
1526
|
settings = read_json("settings.json", {})
|
|
1531
1527
|
llm_settings, _ = ensure_llm_provider_cards(settings)
|
|
@@ -23,9 +23,9 @@ def find_account_for_channel(channel: Mapping[str, Any], settings: Mapping[str,
|
|
|
23
23
|
channel_id = _text(channel.get("youtube_channel_id") or channel.get("id"))
|
|
24
24
|
account_id = _text(channel.get("google_account_id"))
|
|
25
25
|
accounts = _accounts(settings)
|
|
26
|
+
if account_id:
|
|
27
|
+
return next((account for account in accounts if _text(account.get("id")) == account_id), None)
|
|
26
28
|
for account in accounts:
|
|
27
|
-
if account_id and _text(account.get("id")) == account_id:
|
|
28
|
-
return account
|
|
29
29
|
known_channels = account.get("channels", [])
|
|
30
30
|
if isinstance(known_channels, list) and any(_text(item.get("youtube_channel_id") or item.get("id")) == channel_id for item in known_channels if isinstance(item, Mapping)):
|
|
31
31
|
return account
|
package/package.json
CHANGED