-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_manifest.py
More file actions
1463 lines (1300 loc) · 54.9 KB
/
Copy pathbuild_manifest.py
File metadata and controls
1463 lines (1300 loc) · 54.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
聚合各官网 / 官方 API 的下载直链,生成 VibeCodingToolsDown/dist/vibecoding/manifest.json。
供 GitHub Pages 发布;auto_update.py 通过 resolve_via=github_pages_manifest 读取。
仅依赖 requests、beautifulsoup4(与仓库 requirements.txt 一致)。
"""
from __future__ import annotations
import argparse
import json
import os
import re
import sys
from datetime import datetime, timezone
from typing import Any
from urllib.parse import quote, unquote
import requests
UA = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
),
"Accept": "application/json, text/html;q=0.9,*/*;q=0.8",
}
GH_ACCEPT = {"Accept": "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28"}
def _github_api_headers() -> dict[str, str]:
h = dict(GH_ACCEPT)
tok = (os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN") or "").strip()
if tok:
h["Authorization"] = f"Bearer {tok}"
return h
def _session():
s = requests.Session()
s.headers.update(UA)
return s
def _item(
item_id: str,
version: str,
downloads: dict[str, dict[str, str] | None],
notes: str | None = None,
) -> dict[str, Any]:
return {
"id": item_id,
"version": version.lstrip("v"),
"version_tag": version if version.startswith("v") else f"v{version}",
"downloads": downloads,
"notes": notes,
}
def fetch_cursor(s: requests.Session) -> dict[str, Any]:
r = s.get(
"https://api.github.com/repos/accesstechnology-mike/cursor-downloads/releases/latest",
headers=_github_api_headers(),
timeout=40,
)
r.raise_for_status()
j = r.json()
tag = (j.get("tag_name") or "").strip() or "unknown"
ver = tag.lstrip("v")
body = j.get("body") or ""
urls = re.findall(r"\((https://downloads\.cursor\.com[^)]+)\)", body)
win = next((u for u in urls if "UserSetup-x64" in u and u.lower().endswith(".exe")), None)
# 新版本多为 .dmg;旧索引可能是 .zip
mac_u = next(
(u for u in urls if "darwin-universal" in u and u.lower().endswith((".dmg", ".zip"))),
None,
)
mac_a = next(
(u for u in urls if "darwin-arm64" in u and u.lower().endswith((".dmg", ".zip"))),
None,
)
# 索引页常只挂 .AppImage.zsync;真实包去掉 .zsync 后缀即可下载
lin_raw = next(
(
u
for u in urls
if "linux" in u
and ("x86_64" in u or "/x64/" in u)
and ".appimage" in u.lower()
),
None,
)
lin = lin_raw[:-6] if lin_raw and lin_raw.lower().endswith(".zsync") else lin_raw
return _item(
"cursor",
ver,
{
"windows": {"url": win, "filename": os.path.basename(win) if win else ""} if win else None,
"darwin": {"url": mac_u or mac_a, "filename": os.path.basename(mac_u or mac_a or "")}
if (mac_u or mac_a)
else None,
"linux": {"url": lin, "filename": os.path.basename(lin) if lin else ""} if lin else None,
},
notes="索引自 accesstechnology-mike/cursor-downloads Release 正文中的官方 CDN 链。",
)
def _vscode_redirect(s: requests.Session, path_suffix: str) -> str:
"""使用微软官方 update 通道解析最终下载 URL(GET + stream,避免部分网络/代理对 HEAD 不跟随)。"""
u = "https://update.code.visualstudio.com/" + path_suffix.lstrip("/")
with s.get(u, allow_redirects=True, timeout=40, stream=True) as r:
r.raise_for_status()
return r.url
def fetch_vscode(s: requests.Session) -> dict[str, Any]:
r = s.get(
"https://api.github.com/repos/microsoft/vscode/releases/latest",
headers=_github_api_headers(),
timeout=40,
)
r.raise_for_status()
j = r.json()
tag = (j.get("tag_name") or "").strip()
ver = tag.lstrip("v")
win_u = _vscode_redirect(s, "latest/win32-x64/stable")
mac_u = _vscode_redirect(s, "latest/darwin-arm64/stable")
lin_u = _vscode_redirect(s, "latest/linux-x64/stable")
downloads = {
"windows": {"url": win_u, "filename": os.path.basename(win_u.split("?", 1)[0])},
"darwin": {"url": mac_u, "filename": os.path.basename(mac_u.split("?", 1)[0])},
"linux": {"url": lin_u, "filename": os.path.basename(lin_u.split("?", 1)[0])},
}
return _item(
"vscode",
ver,
downloads,
notes="版本 tag 来自 GitHub API;安装包 URL 来自 update.code.visualstudio.com GET 重定向链末端(微软官方 CDN)。",
)
def _collect_trae_install_urls(s: requests.Session, page_urls: tuple[str, ...]) -> list[str]:
"""从官网 HTML 中提取 Trae 稳定包直链(历史页为 lf-trae.toscdn.com;新 CDN 为 lf-cdn.trae.*)。"""
pat = re.compile(
r"https://lf-(?:trae\.toscdn\.com|cdn\.trae\.(?:ai|com\.cn))[^\s\"'<>)]*?\.(?:exe|dmg|zip|AppImage)\b",
re.I,
)
seen: set[str] = set()
for page in page_urls:
try:
r = s.get(page, timeout=40)
r.raise_for_status()
for u in pat.findall(r.text):
seen.add(u.split("?", 1)[0])
except Exception:
continue
return sorted(seen)
def fetch_vscodium(s: requests.Session) -> dict[str, Any]:
r = s.get(
"https://api.github.com/repos/VSCodium/vscodium/releases/latest",
headers=_github_api_headers(),
timeout=40,
)
r.raise_for_status()
j = r.json()
tag = (j.get("tag_name") or "").strip()
ver = tag.lstrip("v")
assets = {a.get("name", ""): a.get("browser_download_url", "") for a in (j.get("assets") or [])}
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: n.startswith("VSCodiumUserSetup-x64-") and n.endswith(".exe"))
mac = pick(lambda n: n.startswith("VSCodium-darwin-arm64-") and n.endswith(".zip"))
lin = pick(lambda n: n.startswith("VSCodium-linux-x64-") and n.endswith(".tar.gz"))
return _item("vscodium", ver, {"windows": win, "darwin": mac, "linux": lin}, notes="GitHub API latest assets。")
def _trae_item_from_urls(item_id: str, urls: list[str], notes: str) -> dict[str, Any]:
if not urls:
raise RuntimeError("未解析到 Trae 安装包直链")
# 多页合并时各平台 stable 段可能不一致,取 URL 中出现的最大稳定段,避免 win/mac 错配旧包。
segs = [m.group(1) for u in urls for m in [re.search(r"/releases/stable/([^/]+)/", u)] if m]
def _seg_key(seg: str) -> tuple[int, ...]:
parts = []
for p in seg.split("."):
if p.isdigit():
parts.append(int(p))
else:
parts.append(0)
return tuple(parts)
ver = max(segs, key=_seg_key) if segs else "unknown"
def pick(sub: str):
cand = [u for u in urls if sub in u and f"/releases/stable/{ver}/" in u]
pool = cand if cand else [u for u in urls if sub in u]
for u in pool:
return {"url": u, "filename": os.path.basename(u.split("?", 1)[0])}
return None
win = pick("Trae-Setup-x64") or pick("win32")
mac = pick("darwin-universal") or pick("darwin-arm64") or pick("darwin-x64")
lin = pick("linux-x64") or pick("linux")
return _item(
item_id,
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes=notes,
)
def _trae_icube_pick_region(entries: list[Any], region_order: tuple[str, ...]) -> dict[str, Any] | None:
if not isinstance(entries, list):
return None
by_reg: dict[str, dict[str, Any]] = {}
for e in entries:
if not isinstance(e, dict):
continue
reg = (e.get("region") or "").strip()
if reg:
by_reg[reg] = e
for reg in region_order:
if reg in by_reg:
return by_reg[reg]
for e in entries:
if isinstance(e, dict):
return e
return None
def _fetch_trae_from_icube_api(
s: requests.Session,
*,
item_id: str,
api_url: str,
region_order: tuple[str, ...],
notes: str,
data_key: str = "manifest",
) -> dict[str, Any] | None:
"""官方 icube native 接口:data.manifest 为 Trae IDE;data.solo 为 TRAE_SOLO(与 https://solo.trae.cn/ 对应)。"""
try:
r = s.get(api_url, timeout=40)
r.raise_for_status()
j = r.json()
except Exception:
return None
if not isinstance(j, dict) or not j.get("success"):
return None
data = j.get("data")
if not isinstance(data, dict):
return None
branch = data.get(data_key)
if not isinstance(branch, dict):
return None
win_blk = branch.get("win32")
dar_blk = branch.get("darwin")
lin_blk = branch.get("linux")
ver = "unknown"
if isinstance(win_blk, dict) and (win_blk.get("version") or "").strip():
ver = str(win_blk["version"]).strip()
elif isinstance(dar_blk, dict) and (dar_blk.get("version") or "").strip():
ver = str(dar_blk["version"]).strip()
elif isinstance(lin_blk, dict) and (lin_blk.get("version") or "").strip():
ver = str(lin_blk["version"]).strip()
win = mac = lin = None
if isinstance(win_blk, dict):
ent = _trae_icube_pick_region(win_blk.get("download") or [], region_order)
if ent:
u = ent.get("x64") or ent.get("x86")
if isinstance(u, str) and u.startswith("http"):
win = {"url": u.split("?", 1)[0], "filename": os.path.basename(u.split("?", 1)[0])}
if isinstance(dar_blk, dict):
ent = _trae_icube_pick_region(dar_blk.get("download") or [], region_order)
if ent:
u = ent.get("apple") or ent.get("arm64") or ent.get("intel") or ent.get("x64")
if isinstance(u, str) and u.startswith("http"):
mac = {"url": u.split("?", 1)[0], "filename": os.path.basename(u.split("?", 1)[0])}
if isinstance(lin_blk, dict):
ent = _trae_icube_pick_region(lin_blk.get("download") or [], region_order)
if ent:
u = (
ent.get("x64.tar.gz")
or ent.get("x64.tar")
or ent.get("amd64.tar.gz")
or ent.get("x64.AppImage")
)
if isinstance(u, str) and u.startswith("http"):
lin = {"url": u.split("?", 1)[0], "filename": os.path.basename(u.split("?", 1)[0])}
if not win and not mac and not lin:
return None
return _item(item_id, ver, {"windows": win, "darwin": mac, "linux": lin}, notes=notes)
def fetch_trae(s: requests.Session) -> dict[str, Any]:
item = _fetch_trae_from_icube_api(
s,
item_id="trae",
api_url="https://api.trae.ai/icube/api/v1/native/version/trae/latest",
region_order=("va", "sg", "usttp", "cn"),
data_key="manifest",
notes=(
"优先 api.trae.ai/icube/.../trae/latest(manifest);下载链优先 region=va,失败则 sg/usttp/cn。"
" version 为接口返回的稳定构建号(与 URL 路径一致);应用内「关于」若显示 3.x 等为另一口径,以本构建号为准。"
),
)
if item is not None:
return item
pages = (
"https://www.trae.ai/download",
"https://traeide.com/download",
)
urls = _collect_trae_install_urls(s, pages)
return _trae_item_from_urls(
"trae",
urls,
notes="API 不可用时回退:扫描下载页 HTML 中的 lf-trae / lf-cdn 直链(多源合并,按 stable 段取较新)。",
)
def fetch_trae_cn(s: requests.Session) -> dict[str, Any]:
item = _fetch_trae_from_icube_api(
s,
item_id="trae_cn",
api_url="https://api.trae.cn/icube/api/v1/native/version/trae/latest",
region_order=("cn", "va", "sg", "usttp"),
data_key="manifest",
notes=(
"优先 api.trae.cn/icube/.../trae/latest;下载链优先 region=cn。"
" version 为接口稳定构建号;与海外 manifest 分支可能不同步。"
),
)
if item is not None:
return item
pages = (
"https://www.trae.cn/ide/download",
"https://www.trae.ai/download",
"https://traeide.com/download",
)
urls = _collect_trae_install_urls(s, pages)
return _trae_item_from_urls(
"trae_cn",
urls,
notes="API 不可用时回退:扫描 trae.cn / trae.ai / traeide 下载页 HTML 直链。",
)
def fetch_trae_solo(s: requests.Session) -> dict[str, Any]:
"""TRAE_SOLO:与 https://solo.trae.cn/ 对应;icube 的 data.solo 当前多为 darwin dmg,Windows 安装包见官网。"""
item = _fetch_trae_from_icube_api(
s,
item_id="trae_solo",
api_url="https://api.trae.ai/icube/api/v1/native/version/trae/latest",
region_order=("va", "sg", "usttp", "cn"),
data_key="solo",
notes=(
"api.trae.ai icube latest 的 data.solo(与 TRAE SOLO 安装包一致)。"
" 官网:https://solo.trae.cn/ 、https://www.trae.cn/solo 。"
" 当前接口多为 macOS dmg;windows/linux 常为 null 时请从官网获取。"
),
)
if item is not None:
return item
return _item(
"trae_solo",
"0",
{"windows": None, "darwin": None, "linux": None},
notes="未能从 icube 解析 TRAE_SOLO;请打开 https://solo.trae.cn/ 或 https://www.trae.cn/solo 手动下载。",
)
def fetch_antigravity(s: requests.Session) -> dict[str, Any]:
"""从 antigravity.google/download 提取 edgedl.me.gvt1.com 直链(HTML 内嵌,或 Astro/旧 main-*.js)。"""
page_url = "https://antigravity.google/download"
r = s.get(page_url, timeout=40)
r.raise_for_status()
html = r.text
pat = re.compile(
r"https://edgedl\.me\.gvt1\.com/edgedl/release2/[a-z0-9]+/antigravity/stable/"
r"\d+\.\d+\.\d+-\d+/[^\"'\\\s<>)]+\.(?:exe|dmg|tar\.gz)\b",
re.I,
)
urls = sorted(set(pat.findall(html)))
source = page_url
if not urls:
# 兼容旧版 SPA:main-*.js;以及当前 Astro:/_astro/*.js
script_srcs: list[str] = []
m = re.search(r'src="(main-[A-Z0-9]+\.js)"', html)
if m:
script_srcs.append("https://antigravity.google/" + m.group(1))
for rel in re.findall(r'src="(/_astro/[^"]+\.js)"', html):
script_srcs.append("https://antigravity.google" + rel)
for bundle_url in script_srcs:
try:
br = s.get(bundle_url, timeout=60)
br.raise_for_status()
found = pat.findall(br.text)
if found:
urls = sorted(set(found))
source = bundle_url
break
except Exception:
continue
if not urls:
raise RuntimeError("Antigravity 下载页未匹配到 edgedl 安装包 URL")
def pick(pred):
for u in urls:
if pred(u):
raw = os.path.basename(u.split("?", 1)[0])
return {"url": u, "filename": unquote(raw)}
return None
win = pick(lambda u: "windows-x64" in u and u.lower().endswith(".exe"))
mac = pick(lambda u: "darwin-arm" in u and u.lower().endswith(".dmg")) or pick(
lambda u: "darwin-x64" in u and u.lower().endswith(".dmg")
)
lin = pick(lambda u: "linux-x64" in u and u.lower().endswith(".tar.gz"))
vers = [
m.group(1)
for u in urls
for m in [re.search(r"/stable/(\d+\.\d+\.\d+)-\d+/", u)]
if m
]
ver = max(vers, key=_qoder_alicdn_version_sort_key) if vers else "unknown"
return _item(
"antigravity",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes=f"自 {source} 解析 Google CDN(edgedl.me.gvt1.com)。",
)
def _gh_latest_assets(s: requests.Session, owner: str, repo: str) -> tuple[str, dict[str, str]]:
"""GitHub releases/latest:返回 tag_name 与 name→browser_download_url 映射。"""
r = s.get(
f"https://api.github.com/repos/{owner}/{repo}/releases/latest",
headers=_github_api_headers(),
timeout=40,
)
r.raise_for_status()
j = r.json()
tag = (j.get("tag_name") or "").strip() or "unknown"
assets = {
(a.get("name") or ""): (a.get("browser_download_url") or "")
for a in (j.get("assets") or [])
if a.get("name")
}
return tag, assets
def fetch_cyberduck(s: requests.Session) -> dict[str, Any]:
"""Cyberduck:iterate-ch/cyberduck 无 GitHub Release;从 cyberduck.io/download 解析 update.cyberduck.io 直链。"""
r = s.get("https://cyberduck.io/download/", timeout=40)
r.raise_for_status()
html = r.text.replace("\\/", "/")
win_m = re.search(
r"https://update\.cyberduck\.io/windows/Cyberduck-Installer-([\d.]+)\.exe",
html,
re.I,
)
mac_m = re.search(
r"https://update\.cyberduck\.io/Cyberduck-([\d.]+)\.zip",
html,
re.I,
)
if not win_m and not mac_m:
raise RuntimeError("未能从 cyberduck.io/download 解析安装包 URL")
ver = win_m.group(1) if win_m else mac_m.group(1)
win = (
{"url": win_m.group(0), "filename": os.path.basename(win_m.group(0))}
if win_m
else None
)
mac = (
{"url": mac_m.group(0), "filename": os.path.basename(mac_m.group(0))}
if mac_m
else None
)
return _item(
"cyberduck",
ver,
{"windows": win, "darwin": mac, "linux": None},
notes=(
"源码 iterate-ch/cyberduck;安装包来自 update.cyberduck.io(非 GitHub Release)。"
" macOS 为 .zip;Linux 请用发行版仓库或官网安装说明。"
),
)
def fetch_restic(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "restic", "restic")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: "windows_amd64" in n and n.endswith(".zip"))
mac = pick(lambda n: "darwin_arm64" in n and n.endswith(".bz2")) or pick(
lambda n: "darwin_amd64" in n and n.endswith(".bz2")
)
lin = pick(lambda n: "linux_amd64" in n and n.endswith(".bz2"))
return _item(
"restic",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes="GitHub restic/restic latest;Windows zip;macOS 优先 arm64 .bz2 否则 amd64;Linux 为 amd64 .bz2(arm64 请用发行版或主仓库 apps 分架构项)。",
)
def fetch_virtualbox(s: requests.Session) -> dict[str, Any]:
"""VirtualBox:无 GitHub Release;从 virtualbox.org/wiki/Downloads 解析 download.virtualbox.org 直链。"""
r = s.get("https://www.virtualbox.org/wiki/Downloads", timeout=40)
r.raise_for_status()
html = r.text.replace("\\/", "/")
urls = sorted(
set(
re.findall(
r"https://download\.virtualbox\.org/virtualbox/[\d.]+/"
r"VirtualBox-[\d.]+-\d+-[^\s\"'<>]+\.(?:exe|dmg|tar\.bz2)",
html,
re.I,
)
)
)
if not urls:
raise RuntimeError("未能从 virtualbox.org/wiki/Downloads 解析安装包 URL")
def pick(pred):
for u in urls:
if pred(u):
return {"url": u, "filename": os.path.basename(u)}
return None
win = pick(lambda u: u.endswith("-Win.exe"))
mac = pick(lambda u: "macOSArm64.dmg" in u) or pick(lambda u: u.endswith("-OSX.dmg"))
lin = pick(lambda u: re.search(r"VirtualBox-[\d.]+\.tar\.bz2$", u, re.I))
ver_m = re.search(r"/virtualbox/([\d.]+)/", urls[0])
ver = ver_m.group(1) if ver_m else "unknown"
return _item(
"virtualbox",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes=(
"Oracle VirtualBox;安装包来自 download.virtualbox.org(非 GitHub Release)。"
" macOS 优先 Apple Silicon dmg;Linux 为通用 tar.bz2,各发行版 deb/rpm 见官网。"
),
)
def _oray_client_software(s: requests.Session, key: str, **params: Any) -> dict[str, Any]:
q = "&".join(f"{k}={v}" for k, v in params.items())
url = f"https://client-api.oray.com/softwares/{key}"
if q:
url += "?" + q
r = s.get(url, timeout=40)
r.raise_for_status()
return r.json()
def _normalize_oray_download_url(url: str) -> str:
u = (url or "").strip()
if not u:
return u
if u.startswith("https://dl.oray.com/"):
return u.replace("https://dl.oray.com/", "https://d-cdn.oray.com/", 1)
return u
def _oray_download_block(url: str | None) -> dict[str, str] | None:
u = _normalize_oray_download_url((url or "").strip())
if not u:
return None
return {"url": u, "filename": os.path.basename(u)}
def _oray_linux_deb_url(data: dict[str, Any]) -> str | None:
for item in data.get("downloadurlmultiple") or []:
name = (item.get("name") or "").lower()
url = (item.get("url") or "").strip()
if url and ("ubuntu" in name or "deepin" in name):
return url
url = (data.get("downloadurl") or "").strip()
return url if url.endswith(".deb") else None
def fetch_sunlogin(s: requests.Session) -> dict[str, Any]:
"""向日葵个人版(AweSun):官方 client-api.oray.com 提供版本与 CDN 直链。"""
win = _oray_client_software(s, "SUNLOGIN_X_WINDOWS", x64=1)
mac_intel = _oray_client_software(s, "SUNLOGIN_X_MAC")
mac_arm = _oray_client_software(s, "SUNLOGIN_X_MAC_ARM")
lin = _oray_client_software(s, "SUNLOGIN_X_LINUX", x64=1)
ver = (win.get("versionno") or "").strip() or "unknown"
mac_url = (mac_arm.get("downloadurl") or "").strip() or (mac_intel.get("downloadurl") or "").strip()
return _item(
"sunlogin",
ver,
{
"windows": _oray_download_block(win.get("downloadurl")),
"darwin": _oray_download_block(mac_url),
"linux": _oray_download_block(_oray_linux_deb_url(lin)),
},
notes=(
"贝锐向日葵个人版(AweSun);版本与直链来自 client-api.oray.com。"
" 下载 oray CDN 时需 Referer(auto_update 已自动附加 sunlogin.oray.com)。"
" macOS 优先 arm64 dmg;Linux 为 deb(Ubuntu/Deepin)。"
),
)
def _termius_electron_release(
s: requests.Session, cdn_base: str, yml_name: str, artifact: str
) -> tuple[str, str]:
"""从 Termius autoupdate.termius.com 的 electron-builder yml 取版本与直链。"""
yml_url = f"{cdn_base.rstrip('/')}/{yml_name}"
r = s.get(yml_url, timeout=40)
r.raise_for_status()
text = r.text
ver_m = re.search(r"^version:\s*['\"]?([^\s'\"]+)", text, re.M)
if not ver_m:
raise RuntimeError("未能从 %s 解析 version" % yml_url)
ver = ver_m.group(1).strip()
file_url = f"{cdn_base.rstrip('/')}/{quote(artifact, safe='')}"
return ver, file_url
def fetch_termius(s: requests.Session) -> dict[str, Any]:
"""Termius:跨平台 SSH 终端;autoupdate.termius.com + download.termius.com。"""
win_ver, win_url = _termius_electron_release(
s, "https://autoupdate.termius.com/windows", "latest.yml", "Install Termius.exe"
)
_, mac_arm_url = _termius_electron_release(
s, "https://autoupdate.termius.com/mac-arm64", "latest-mac.yml", "Termius.dmg"
)
_, mac_intel_url = _termius_electron_release(
s, "https://autoupdate.termius.com/mac", "latest-mac.yml", "Termius.dmg"
)
deb_r = s.head(
"https://www.termius.com/download/linux/Termius.deb",
timeout=40,
allow_redirects=True,
)
deb_r.raise_for_status()
deb_url = deb_r.url
def blk(url: str | None, filename: str = "") -> dict[str, str] | None:
if not url:
return None
name = filename or os.path.basename(url.split("?", 1)[0])
return {"url": url, "filename": name}
mac_url = mac_arm_url or mac_intel_url
return _item(
"termius",
win_ver,
{
"windows": blk(win_url, "Install Termius.exe"),
"darwin": blk(mac_url, "Termius.dmg"),
"linux": blk(deb_url, "Termius.deb"),
},
notes=(
"Termius 跨平台 SSH 终端;版本来自 autoupdate.termius.com electron-builder yml。"
" macOS 优先 arm64 dmg;Linux 为官方 Termius.deb(download.termius.com)。"
),
)
def fetch_cutter(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "rizinorg", "cutter")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: "Windows" in n and n.endswith(".zip"))
mac = pick(lambda n: "macOS-arm64" in n and n.endswith(".dmg")) or pick(
lambda n: "macOS" in n and n.endswith(".dmg")
)
lin = pick(lambda n: "Linux" in n and n.endswith(".AppImage") and "Qt5" not in n) or pick(
lambda n: "Linux" in n and "AppImage" in n
)
return _item(
"cutter",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes="GitHub rizinorg/cutter latest;Windows zip;macOS dmg;Linux AppImage(优先非 Qt5 构建)。",
)
def fetch_syncthing(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "syncthing", "syncthing")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: n.startswith("syncthing-windows-amd64-") and n.endswith(".zip"))
mac = pick(lambda n: "syncthing-macos-universal-" in n and n.endswith(".zip"))
lin = pick(lambda n: n.startswith("syncthing-linux-amd64-") and n.endswith(".tar.gz"))
return _item(
"syncthing",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes="GitHub syncthing/syncthing latest;仅核心压缩包,不含安装器。",
)
def fetch_sqlitebrowser(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "sqlitebrowser", "sqlitebrowser")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: "DB.Browser.for.SQLite-" in n and n.endswith("-win64.msi"))
mac = pick(lambda n: n.startswith("DB.Browser.for.SQLite-") and n.endswith(".dmg") and "arm64" not in n)
lin = pick(lambda n: "x86.64" in n and n.endswith(".AppImage"))
return _item(
"sqlitebrowser",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes="GitHub sqlitebrowser/sqlitebrowser latest;Linux 为 x86_64 AppImage(文件名含 x86.64)。",
)
def fetch_caesium(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "Lymphatus", "caesium-image-compressor")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: "win-setup.exe" in n and n.endswith(".exe"))
mac = pick(lambda n: "-macos.dmg" in n and n.endswith(".dmg"))
return _item(
"caesium",
ver,
{"windows": win, "darwin": mac, "linux": None},
notes="GitHub Lymphatus/caesium-image-compressor latest;Linux 无 Release 通用包(见主仓库 apps/linux/11-工具 说明)。",
)
def fetch_cc_switch(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "farion1231", "cc-switch")
ver = tag.lstrip("v") if tag.startswith("v") else tag
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: n.startswith("CC-Switch-") and n.endswith("-Windows.msi"))
mac = pick(lambda n: n.startswith("CC-Switch-") and n.endswith("-macOS.dmg"))
lin = pick(lambda n: "Linux-x86_64.AppImage" in n and n.endswith(".AppImage"))
return _item(
"cc_switch",
ver,
{"windows": win, "darwin": mac, "linux": lin},
notes="GitHub farion1231/cc-switch(CC Switch);Windows MSI、macOS dmg、Linux x86_64 AppImage。",
)
def fetch_aria2(s: requests.Session) -> dict[str, Any]:
tag, assets = _gh_latest_assets(s, "aria2", "aria2")
m = re.match(r"(?:release-)?(\d+\.\d+\.\d+)\b", tag)
ver = m.group(1) if m else tag.replace("release-", "").lstrip("v")
def pick(pred):
for name, u in assets.items():
if pred(name):
return {"url": u, "filename": name}
return None
win = pick(lambda n: "win-64bit" in n and n.endswith(".zip"))
return _item(
"aria2",
ver,
{"windows": win, "darwin": None, "linux": None},
notes="GitHub aria2/aria2 latest;仅 Windows 64 位 zip。macOS/Linux 请用 brew / 发行版包或源码编译。",
)
def fetch_kiro(s: requests.Session) -> dict[str, Any]:
r = s.get("https://prod.download.cli.kiro.dev/stable/latest/manifest.json", timeout=40)
r.raise_for_status()
j = r.json()
ver = str(j.get("version") or "unknown")
base_latest = "https://prod.download.cli.kiro.dev/stable/latest/"
packages = j.get("packages") or []
def pick_pkg(**kw):
for p in packages:
if not all(p.get(k) == v for k, v in kw.items()):
continue
rel = p.get("download") or ""
fname = rel.split("/")[-1]
if not fname:
continue
url = base_latest + quote(fname, safe="")
return {"url": url, "filename": fname}
return None
return _item(
"kiro",
ver,
{
"windows": pick_pkg(
os="windows", fileType="msi", variant="full", architecture="x86_64"
),
"darwin": pick_pkg(
os="macos", fileType="dmg", variant="full", architecture="universal"
),
"linux": pick_pkg(
os="linux", fileType="appImage", variant="full", architecture="x86_64"
)
or pick_pkg(os="linux", fileType="deb", variant="full", architecture="x86_64"),
},
notes="Kiro CLI 官方 manifest(含 Windows MSI / macOS dmg / Linux AppImage 等)。",
)
def _qoder_alicdn_version_sort_key(v: str) -> tuple[int, ...]:
out: list[int] = []
for p in v.split("."):
if p.isdigit():
out.append(int(p))
else:
nums = "".join(c for c in p if c.isdigit())
out.append(int(nums) if nums else 0)
return tuple(out)
def fetch_zcode(s: requests.Session) -> dict[str, Any]:
"""ZCode 桌面端:从 zcode.z.ai 首页解析 cdn-zcode.z.ai 最新版本与安装包直链。"""
vers: set[str] = set()
last_err: Exception | None = None
for page in ("https://zcode.z.ai/", "https://zcode.z.ai/en", "https://zcode.z.ai/cn"):
try:
r = s.get(page, timeout=40)
r.raise_for_status()
except Exception as e:
last_err = e
continue
html = r.text
vers.update(re.findall(r"cdn-zcode\.z\.ai/zcode/electron/releases/([\d.]+)/", html))
vers.update(re.findall(r"cdn\.zcode-ai\.com/zcode/electron/releases/([\d.]+)/", html))
if not vers:
detail = f"(末次错误: {last_err})" if last_err else ""
raise RuntimeError("无法从 zcode.z.ai 解析版本号" + detail)
ver = max(vers, key=_qoder_alicdn_version_sort_key)
base = f"https://cdn-zcode.z.ai/zcode/electron/releases/{ver}/"
def pkg(name: str) -> dict[str, str]:
return {"url": base + name, "filename": name}
return _item(
"zcode",
ver,
{
"windows": pkg(f"ZCode-{ver}-win-x64.exe"),
"darwin": pkg(f"ZCode-{ver}-mac-arm64.dmg"),
"linux": pkg(f"ZCode-{ver}-linux-x64.AppImage"),
},
notes="自 zcode.z.ai 首页 CDN(cdn-zcode.z.ai)解析;Intel Mac 可用 mac-x64.dmg。",
)
def _qoder_install_urls_from_site_chunks(
s: requests.Session, html: str, page_url: str
) -> tuple[str, list[str]]:
"""从 qoder.com 本站 Next.js chunks 解析 download.qoder.com 安装包直链(2026 起主路径)。"""
origin_m = re.match(r"(https://[^/]+)", page_url)
origin = origin_m.group(1) if origin_m else "https://qoder.com"
chunk_paths = sorted(set(re.findall(r'/_next/static/chunks/[^"\']+\.js', html)))
inst_pat = re.compile(
r"https://[a-zA-Z0-9./_?=&%-]{12,500}\.(?:exe|dmg|deb|rpm|AppImage)\b",
re.I,
)
found: set[str] = set()
for rel in chunk_paths[:55]:
ju = origin + rel
try:
jr = s.get(ju, timeout=40)
jr.raise_for_status()
body = jr.text.replace("\\/", "/")
for u in inst_pat.findall(body):
if "${" in u or "{" in u:
continue
found.add(u.split("?", 1)[0])
except Exception:
continue
if not found:
return "unknown", []
vers = re.findall(
r"(?:Qoder|qoder)[-_]?(\d+\.\d+\.\d+)",
" ".join(found),
flags=re.I,
)
ver = max(vers, key=_qoder_alicdn_version_sort_key) if vers else "latest"
return ver, sorted(found)
def _qoder_install_urls_from_chunks(s: requests.Session, html: str) -> tuple[str, list[str]]:
"""从 qoder.com 下载页 HTML 解析 alicdn 版本号并扫描 _next/static/chunks 下的 JS 直链。"""
vers = sorted(
set(re.findall(r"g\.alicdn\.com/Qoder/qoder-web/([\d.]+)/", html)),
key=_qoder_alicdn_version_sort_key,
)
if not vers:
return "unknown", []
ver = vers[-1]
base = f"https://g.alicdn.com/Qoder/qoder-web/{ver}/"
js_paths = sorted(
set(
re.findall(
rf"https://g\.alicdn\.com/Qoder/qoder-web/{re.escape(ver)}/_next/static/chunks/[^\"']+\.js",
html,
)
)
)
if not js_paths:
# 协议相对 URL
rel = sorted(
set(
re.findall(
rf"//g\.alicdn\.com/Qoder/qoder-web/{re.escape(ver)}/_next/static/chunks/[^\"']+\.js",
html,
)
)
)
js_paths = ["https:" + u if u.startswith("//") else u for u in rel]
inst_pat = re.compile(
r"https://[a-zA-Z0-9./_?=&%-]{12,500}\.(?:exe|dmg|deb|rpm|AppImage)\b",
re.I,
)
found: set[str] = set()
for ju in js_paths[:45]:
try:
jr = s.get(ju, timeout=40)
jr.raise_for_status()
body = jr.text.replace("\\/", "/")
for u in inst_pat.findall(body):
if "${" in u or "{" in u:
continue
found.add(u.split("?", 1)[0])
except Exception:
continue
return ver, sorted(found)
def _pick_qoder_installers(hits: list[str]) -> tuple[str | None, str | None, str | None]:
"""优先选 Qoder IDE 包,避免误选 QoderWork / QoderWake 独立应用。"""
def is_work(u: str) -> bool:
x = u.lower()
return (
"qoderwork" in x
or "qoder-work" in x
or "qoder_work" in x
or "qoderwake" in x
)
win_pool = [h for h in hits if h.lower().endswith(".exe") and not is_work(h)]
win = next((h for h in win_pool if "usersetup" not in h.lower() and "setup" in h.lower()), None) or (
win_pool[0] if win_pool else None
)
mac_pool = [h for h in hits if h.lower().endswith(".dmg") and not is_work(h)]
mac = next((h for h in mac_pool if "arm64" in h.lower()), None) or (mac_pool[0] if mac_pool else None)
lin = next((h for h in hits if h.lower().endswith((".deb", ".rpm", ".appimage")) and not is_work(h)), None)
return win, mac, lin