mirror of
https://github.com/wcbing/wcbing-apt-repo.git
synced 2025-12-29 02:28:30 +08:00
feat: Support for Git hosting sites like Github
This commit is contained in:
parent
251b5233c5
commit
51a7d954e6
@ -17,7 +17,7 @@ def read_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-d", "--data", default="data", help="从 <DATA> 读取仓库配置")
|
||||
parser.add_argument(
|
||||
"-p", "--proxy", default="", help="Github 代理,<PROXY> 必须以 / 结尾"
|
||||
"-p", "--proxy", default="", help="Github 代理"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t", "--thread", type=int, default=5, help="并发下载线程数量,默认为 5"
|
||||
@ -36,11 +36,13 @@ if __name__ == "__main__":
|
||||
tasks = []
|
||||
with ThreadPoolExecutor(max_workers=CONFIG["thread"]) as executor:
|
||||
for name, repo in github_info_list.items():
|
||||
release_url = (
|
||||
f'{CONFIG["proxy"]}https://github.com/{repo["repo"]}/releases'
|
||||
)
|
||||
if "site" in repo:
|
||||
repo_url = os.path.join(repo["site"], repo['repo'])
|
||||
else:
|
||||
# 默认认为是 GitHub 仓库地址,同时使用代理
|
||||
repo_url = os.path.join(CONFIG["proxy"], "https://github.com", repo["repo"])
|
||||
# get latest releases tag 获取最新版本标签
|
||||
location = requests.head(release_url + "/latest").headers.get("Location", "")
|
||||
location = requests.head(repo_url + "/releases/latest").headers.get("Location", "")
|
||||
match = re.search(r".*releases/tag/(.*)", location)
|
||||
if not match:
|
||||
continue
|
||||
@ -52,7 +54,7 @@ if __name__ == "__main__":
|
||||
release_file = file_name.format(
|
||||
releases_tag=releases_tag, version=version
|
||||
)
|
||||
file_url = f"{release_url}/download/{releases_tag}/{release_file}"
|
||||
file_url = f"{repo_url}/releases/download/{releases_tag}/{release_file}"
|
||||
# 提交任务到线程池
|
||||
tasks.append(
|
||||
executor.submit(check_download, name, version, file_url, arch)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user