@danhachuel/thunderbolt 0.4.46 → 0.4.47
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 +27 -12
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -1858,6 +1858,16 @@ def _tiktok_channel_records() -> list[dict[str, Any]]:
|
|
|
1858
1858
|
return [channel for channel in read_json("channels.json", []) if isinstance(channel, dict) and channel.get("platform") == "tiktok"]
|
|
1859
1859
|
|
|
1860
1860
|
|
|
1861
|
+
def _tiktok_avatar_url(value: dict[str, Any]) -> str:
|
|
1862
|
+
for key in ("avatar_url", "thumbnail_url", "profile_image_url", "avatar", "image_url"):
|
|
1863
|
+
candidate = value.get(key)
|
|
1864
|
+
if isinstance(candidate, dict):
|
|
1865
|
+
candidate = candidate.get("url") or candidate.get("src")
|
|
1866
|
+
if str(candidate or "").strip():
|
|
1867
|
+
return str(candidate).strip()
|
|
1868
|
+
return ""
|
|
1869
|
+
|
|
1870
|
+
|
|
1861
1871
|
def _tiktok_prompt_options() -> tuple[list[str], dict[str, str]]:
|
|
1862
1872
|
files = list_prompt_master_files()
|
|
1863
1873
|
labels = {path.name: get_display_name("prompt_masters", path, path.stem) for path in files}
|
|
@@ -1893,7 +1903,7 @@ def render_tiktok_channels():
|
|
|
1893
1903
|
with st.container(border=True):
|
|
1894
1904
|
profile_cols = st.columns([0.8, 2.2, 1, 1, 1])
|
|
1895
1905
|
with profile_cols[0]:
|
|
1896
|
-
avatar =
|
|
1906
|
+
avatar = _tiktok_avatar_url(imported)
|
|
1897
1907
|
if avatar:
|
|
1898
1908
|
st.image(avatar, width=82)
|
|
1899
1909
|
else:
|
|
@@ -1932,7 +1942,8 @@ def render_tiktok_channels():
|
|
|
1932
1942
|
description = st.text_area("Descrição", value=str(imported.get("bio") or ""), key="tiktok_import_description")
|
|
1933
1943
|
if st.form_submit_button("Cadastrar canal TikTok", type="primary"):
|
|
1934
1944
|
channel = create_channel(name.strip(), url.strip(), {"platform": "tiktok", "handle": handle.strip(), "language": language, "niche": niche.strip(), "description": description.strip(), "default_prompt_master": prompt, "prompt_master": prompt, "style_wide": "portrait", "video_aspect_ratio": "Portrait 9:16", "metrics_source": "tiktok_public_page", "subscriber_count": imported.get("subscriber_count"), "video_count": imported.get("video_count")})
|
|
1935
|
-
|
|
1945
|
+
avatar_url = _tiktok_avatar_url(imported)
|
|
1946
|
+
update_channel(channel["id"], {"platform": "tiktok", "default_prompt_master": prompt, "prompt_master": prompt, "avatar_url": avatar_url, "thumbnail_url": avatar_url})
|
|
1936
1947
|
st.session_state.pop("tiktok_channel_import", None)
|
|
1937
1948
|
st.success(f"Canal {channel['name']} cadastrado.")
|
|
1938
1949
|
st.rerun()
|
|
@@ -1953,6 +1964,17 @@ def render_tiktok_channels():
|
|
|
1953
1964
|
st.success(f"{created} canal(is) TikTok cadastrado(s).")
|
|
1954
1965
|
st.rerun()
|
|
1955
1966
|
st.caption("A planilha usa os campos de URL, nome, handle, idioma, nicho, Prompt Master, descrição e horário.")
|
|
1967
|
+
st.divider()
|
|
1968
|
+
st.subheader(f"Canais TikTok cadastrados ({len(channels)})")
|
|
1969
|
+
if channels:
|
|
1970
|
+
st.dataframe(
|
|
1971
|
+
[{k: c.get(v, "") for k, v in {"URL canal": "url", "Nome canal": "name", "Handle canal": "handle", "Idioma": "language", "Nicho": "niche", "Prompt Master": "default_prompt_master", "Proporção": "video_aspect_ratio", "Activo": "active", "Descrição": "description"}.items()} for c in channels],
|
|
1972
|
+
use_container_width=True,
|
|
1973
|
+
hide_index=True,
|
|
1974
|
+
height=360,
|
|
1975
|
+
)
|
|
1976
|
+
else:
|
|
1977
|
+
st.info("Ainda não existem canais TikTok cadastrados.")
|
|
1956
1978
|
with manual_tab:
|
|
1957
1979
|
with st.form("tiktok_channel_manual_form"):
|
|
1958
1980
|
url = st.text_input("URL canal", placeholder="https://www.tiktok.com/@conta", key="tiktok_manual_channel_url")
|
|
@@ -1968,14 +1990,6 @@ def render_tiktok_channels():
|
|
|
1968
1990
|
update_channel(channel["id"], {"platform": "tiktok"})
|
|
1969
1991
|
st.success("Canal TikTok cadastrado.")
|
|
1970
1992
|
st.rerun()
|
|
1971
|
-
st.divider()
|
|
1972
|
-
st.subheader(f"Canais TikTok cadastrados ({len(channels)})")
|
|
1973
|
-
if channels:
|
|
1974
|
-
st.dataframe([{k: c.get(v, "") for k, v in {"URL canal": "url", "Nome canal": "name", "Handle canal": "handle", "Idioma": "language", "Nicho": "niche", "Prompt Master": "default_prompt_master", "Proporção": "video_aspect_ratio", "Activo": "active", "Descrição": "description"}.items()} for c in channels], use_container_width=True, hide_index=True, height=360)
|
|
1975
|
-
else:
|
|
1976
|
-
st.info("Ainda não existem canais TikTok cadastrados.")
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
1993
|
def render_channels():
|
|
1980
1994
|
st.title("Canais Youtube")
|
|
1981
1995
|
st.caption("Escolha entre importar dados públicos do YouTube ou preencher o canal manualmente.")
|
|
@@ -4607,7 +4621,7 @@ def render_tiktok_automation():
|
|
|
4607
4621
|
with st.container(border=True):
|
|
4608
4622
|
header_cols = st.columns([0.55, 2.35, 1.35, 1.5, 1.35])
|
|
4609
4623
|
with header_cols[0]:
|
|
4610
|
-
profile_image =
|
|
4624
|
+
profile_image = _tiktok_avatar_url(channel)
|
|
4611
4625
|
if profile_image:
|
|
4612
4626
|
st.image(profile_image, width=48)
|
|
4613
4627
|
else:
|
|
@@ -4639,7 +4653,8 @@ def render_tiktok_automation():
|
|
|
4639
4653
|
if not valid_hhmm(schedule_time):
|
|
4640
4654
|
st.error("Use o formato HH:MM, por exemplo 08:30.")
|
|
4641
4655
|
else:
|
|
4642
|
-
|
|
4656
|
+
avatar_url = _tiktok_avatar_url(channel)
|
|
4657
|
+
update_channel(channel_id, {"automation_on": bool(enabled), "automation_time": schedule_time.strip(), "default_prompt_master": prompt, "prompt_master": prompt, "platform": "tiktok", "video_aspect_ratio": "Portrait 9:16", "style_wide": "portrait", "avatar_url": avatar_url, "thumbnail_url": avatar_url})
|
|
4643
4658
|
st.success("Automação TikTok guardada.")
|
|
4644
4659
|
st.rerun()
|
|
4645
4660
|
|
package/package.json
CHANGED