@danhachuel/thunderbolt 0.4.67 → 0.4.68
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 +18 -16
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -1855,8 +1855,20 @@ def format_metric_number(value: Any) -> str:
|
|
|
1855
1855
|
return str(value)
|
|
1856
1856
|
|
|
1857
1857
|
|
|
1858
|
+
def classify_channel_platform(channel: Any) -> str:
|
|
1859
|
+
"""Return the persisted platform, or unknown when it is not explicit."""
|
|
1860
|
+
if not isinstance(channel, dict):
|
|
1861
|
+
return "unknown"
|
|
1862
|
+
value = str(channel.get("platform") or "").strip().casefold().replace(" ", "")
|
|
1863
|
+
if value in {"youtube", "yt"}:
|
|
1864
|
+
return "youtube"
|
|
1865
|
+
if value in {"tiktok", "tik-tok", "tt"}:
|
|
1866
|
+
return "tiktok"
|
|
1867
|
+
return "unknown"
|
|
1868
|
+
|
|
1869
|
+
|
|
1858
1870
|
def _tiktok_channel_records() -> list[dict[str, Any]]:
|
|
1859
|
-
return [channel for channel in read_json("channels.json", []) if
|
|
1871
|
+
return [channel for channel in read_json("channels.json", []) if classify_channel_platform(channel) == "tiktok"]
|
|
1860
1872
|
|
|
1861
1873
|
|
|
1862
1874
|
def _tiktok_avatar_url(value: dict[str, Any]) -> str:
|
|
@@ -2087,18 +2099,8 @@ def render_tiktok_channels():
|
|
|
2087
2099
|
st.success("Canal TikTok cadastrado.")
|
|
2088
2100
|
st.rerun()
|
|
2089
2101
|
def is_youtube_channel_record(channel: Any) -> bool:
|
|
2090
|
-
"""Return whether a persisted channel is
|
|
2091
|
-
|
|
2092
|
-
return False
|
|
2093
|
-
platform = str(channel.get("platform") or "").strip().casefold().replace(" ", "")
|
|
2094
|
-
if platform == "youtube":
|
|
2095
|
-
return True
|
|
2096
|
-
if platform:
|
|
2097
|
-
return False
|
|
2098
|
-
youtube_id = str(channel.get("youtube_id") or channel.get("youtube_channel_id") or "").strip()
|
|
2099
|
-
youtube_url = str(channel.get("url") or channel.get("profile_url") or channel.get("source_url") or "").strip().casefold()
|
|
2100
|
-
source = str(channel.get("metrics_source") or channel.get("import_source") or "").strip().casefold()
|
|
2101
|
-
return bool(youtube_id or "youtube.com" in youtube_url or source.startswith("youtube"))
|
|
2102
|
+
"""Return whether a persisted channel is explicitly identified as YouTube."""
|
|
2103
|
+
return classify_channel_platform(channel) == "youtube"
|
|
2102
2104
|
|
|
2103
2105
|
|
|
2104
2106
|
def render_channels():
|
|
@@ -2861,7 +2863,7 @@ def render_new_video(page_title: str = "Criação de Vídeos", prefix: str = "ne
|
|
|
2861
2863
|
create_tab = tabs[0]
|
|
2862
2864
|
draft_tab = tabs[1] if len(tabs) > 1 else None
|
|
2863
2865
|
with create_tab:
|
|
2864
|
-
all_channels = [c for c in read_json("channels.json", []) if
|
|
2866
|
+
all_channels = [c for c in read_json("channels.json", []) if classify_channel_platform(c) == channel_platform]
|
|
2865
2867
|
active_channels = [c for c in all_channels if c.get("active", True)]
|
|
2866
2868
|
if not all_channels:
|
|
2867
2869
|
st.warning("Cadastre pelo menos um canal antes de criar vídeos.")
|
|
@@ -4804,7 +4806,7 @@ def render_automation():
|
|
|
4804
4806
|
st.caption(f"Última verificação do worker: {last_tick}")
|
|
4805
4807
|
if worker_status.get("last_error"):
|
|
4806
4808
|
st.error(f"Último erro do worker: {worker_status['last_error']}")
|
|
4807
|
-
channels = [channel for channel in read_json("channels.json", []) if
|
|
4809
|
+
channels = [channel for channel in read_json("channels.json", []) if is_youtube_channel_record(channel)]
|
|
4808
4810
|
if not channels:
|
|
4809
4811
|
st.info("Nenhum canal cadastrado para configurar.")
|
|
4810
4812
|
for channel in channels:
|
|
@@ -7900,7 +7902,7 @@ def render_update_youtube_videos():
|
|
|
7900
7902
|
st.title("Update Youtube Vídeos")
|
|
7901
7903
|
st.caption("Actualize título, descrição e thumbnail de vídeos publicados sem alterar o ficheiro de vídeo.")
|
|
7902
7904
|
settings = read_json("settings.json", {})
|
|
7903
|
-
channels = [channel for channel in read_json("channels.json", []) if
|
|
7905
|
+
channels = [channel for channel in read_json("channels.json", []) if is_youtube_channel_record(channel) and channel.get("active", True)]
|
|
7904
7906
|
if not channels:
|
|
7905
7907
|
st.info("Cadastre pelo menos um canal YouTube activo antes de actualizar vídeos.")
|
|
7906
7908
|
return
|
package/package.json
CHANGED