@danhachuel/thunderbolt 0.4.61 → 0.4.63
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 +26 -9
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -2109,15 +2109,29 @@ def render_channels():
|
|
|
2109
2109
|
col1, col2 = st.columns([1, 1])
|
|
2110
2110
|
with col1:
|
|
2111
2111
|
if st.button("Buscar no YouTube", type="primary", use_container_width=True, key="youtube_channel_lookup"):
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2112
|
+
search_source = str(source or "").strip()
|
|
2113
|
+
st.session_state.pop("yt_import", None)
|
|
2114
|
+
st.session_state.pop("yt_message", None)
|
|
2115
|
+
st.session_state.pop("yt_ok", None)
|
|
2116
|
+
if not search_source:
|
|
2117
|
+
st.session_state["yt_message"] = "Introduza um URL youtube.com, um handle @nome ou um ID de canal UC... antes de pesquisar."
|
|
2118
|
+
st.session_state["yt_ok"] = False
|
|
2116
2119
|
else:
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2120
|
+
try:
|
|
2121
|
+
with st.spinner("A pesquisar o canal no YouTube…"):
|
|
2122
|
+
if lookup_mode.startswith("Página pública"):
|
|
2123
|
+
result = youtube.fetch_channel_public(search_source)
|
|
2124
|
+
elif not youtube.api_key:
|
|
2125
|
+
result = IntegrationResult(False, "A YouTube Data API Key não está configurada. Escolha a opção Página pública — sem API Key ou configure a chave em Configurações > Contas Google.", {"status": "api_key_not_configured"})
|
|
2126
|
+
else:
|
|
2127
|
+
result = youtube.fetch_channel(search_source)
|
|
2128
|
+
st.session_state["yt_import"] = result.data if isinstance(result.data, dict) else {}
|
|
2129
|
+
st.session_state["yt_message"] = result.message
|
|
2130
|
+
st.session_state["yt_ok"] = result.ok
|
|
2131
|
+
except Exception as exc:
|
|
2132
|
+
st.session_state["yt_import"] = {}
|
|
2133
|
+
st.session_state["yt_message"] = f"A pesquisa do YouTube falhou ({type(exc).__name__}). Confirme o URL/handle e tente novamente. Detalhe: {str(exc)[:240]}"
|
|
2134
|
+
st.session_state["yt_ok"] = False
|
|
2121
2135
|
with col2:
|
|
2122
2136
|
if st.button("Limpar importação", use_container_width=True, key="youtube_channel_clear"):
|
|
2123
2137
|
for key in ("yt_import", "yt_message", "yt_ok"):
|
|
@@ -2328,7 +2342,10 @@ def render_channels():
|
|
|
2328
2342
|
|
|
2329
2343
|
st.divider()
|
|
2330
2344
|
st.subheader("Canais cadastrados")
|
|
2331
|
-
registered_channels =
|
|
2345
|
+
registered_channels = [
|
|
2346
|
+
channel for channel in read_json("channels.json", [])
|
|
2347
|
+
if isinstance(channel, dict) and str(channel.get("platform") or "youtube").strip().lower() != "tiktok"
|
|
2348
|
+
]
|
|
2332
2349
|
if not registered_channels:
|
|
2333
2350
|
st.info("Nenhum canal cadastrado.")
|
|
2334
2351
|
else:
|
package/package.json
CHANGED