mirror of
https://github.com/wcbing/wcbing-apt-repo.git
synced 2025-12-28 18:18:31 +08:00
feat: Support for Git hosting sites like Github
This commit is contained in:
parent
46943d6a0d
commit
4ba5053ada
@ -17,7 +17,7 @@ def read_args():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-d", "--data", default="data", help="从 <DATA> 读取仓库配置")
|
parser.add_argument("-d", "--data", default="data", help="从 <DATA> 读取仓库配置")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-p", "--proxy", default="", help="Github 代理,<PROXY> 必须以 / 结尾"
|
"-p", "--proxy", default="", help="Github 代理"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-t", "--thread", type=int, default=5, help="并发下载线程数量,默认为 5"
|
"-t", "--thread", type=int, default=5, help="并发下载线程数量,默认为 5"
|
||||||
@ -36,11 +36,13 @@ if __name__ == "__main__":
|
|||||||
tasks = []
|
tasks = []
|
||||||
with ThreadPoolExecutor(max_workers=CONFIG["thread"]) as executor:
|
with ThreadPoolExecutor(max_workers=CONFIG["thread"]) as executor:
|
||||||
for name, repo in github_info_list.items():
|
for name, repo in github_info_list.items():
|
||||||
release_url = (
|
if "site" in repo:
|
||||||
f'{CONFIG["proxy"]}https://github.com/{repo["repo"]}/releases'
|
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 获取最新版本标签
|
# 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)
|
match = re.search(r".*releases/tag/(.*)", location)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
@ -52,7 +54,7 @@ if __name__ == "__main__":
|
|||||||
release_file = file_name.format(
|
release_file = file_name.format(
|
||||||
releases_tag=releases_tag, version=version
|
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(
|
tasks.append(
|
||||||
executor.submit(check_download, name, version, file_url, arch)
|
executor.submit(check_download, name, version, file_url, arch)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user