Skip to content

Commit 670268d

Browse files
committed
feat: update existing links with platform detection
When adding a link that already exists: - Detect platforms from the TestFlight page - Replace existing platform info with newly detected platforms - Log changes if platforms differ - Update app_name and status to latest - Preserve last_modify timestamp This ensures platforms are always up-to-date when re-adding links.
1 parent 29a5ad1 commit 670268d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/add_link.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,33 @@ async def main():
136136
links_data["_links"] = {}
137137

138138
# Check if link already exists
139+
link_exists = testflight_link in links_data["_links"]
139140
link_info = links_data["_links"].get(testflight_link)
141+
140142
if link_info is None:
141143
link_info = {
142144
"app_name": app_name,
143145
"status": status,
144-
"tables": [],
146+
"tables": tables,
145147
"last_modify": TODAY
146148
}
149+
action = "Added new link"
147150
else:
151+
old_platforms = link_info.get("tables", [])
148152
link_info["app_name"] = app_name
149153
link_info["status"] = status
154+
link_info["tables"] = tables # Replace with newly detected platforms
150155
link_info["last_modify"] = TODAY
151-
152-
# Add tables (avoid duplicates)
153-
for table in tables:
154-
if table not in link_info["tables"]:
155-
link_info["tables"].append(table)
156+
157+
# Log platform changes if they differ
158+
if set(old_platforms) != set(tables):
159+
print(f"[info] Updated platforms for '{app_name}': {old_platforms}{tables}")
160+
161+
action = "Updated existing link"
156162

157163
links_data["_links"][testflight_link] = link_info
158164
save_links(links_data)
159-
print(f"[info] Added '{app_name}' to categories: {', '.join(link_info['tables'])}")
165+
print(f"[info] {action} '{app_name}' with platforms: {', '.join(link_info['tables'])}")
160166

161167
# 直接生成 README
162168
renew_readme()

0 commit comments

Comments
 (0)