From bd2c7bc03371206621cb2777801f427be7dac060 Mon Sep 17 00:00:00 2001 From: H-Sofie <2088711818@qq.com> Date: Fri, 31 Jan 2025 12:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=9B=B4=E6=8D=A2=E5=8F=AF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=20CDN=20(#28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update_dir.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/update_dir.py b/update_dir.py index 9ff1b26a4..62b7d30ff 100644 --- a/update_dir.py +++ b/update_dir.py @@ -11,8 +11,8 @@ # 文本文件走 blob 链接(在线查看),其他文件走 cdn 链接(便于直接下载),大文件反代加速 BLOB_URL_PREFIX = f"https://github.com/{repo_full}/blob/{branch}/" -BIN_URL_PREFIX = f"https://cdn.jsdmirror.com/gh/{repo_full}/" -LARGE_URL_PREFIX = f"https://raw.github.site/{repo_full}/refs/heads/{branch}/" +BIN_URL_PREFIX = f"https://gh-proxy.com/raw.githubusercontent.com/{repo_full}/refs/heads/{branch}/" +# LARGE_URL_PREFIX = f"https://gh-proxy.com/raw.githubusercontent.com/{repo_full}/refs/heads/{branch}/" # 大文件阈值 15MB LARGE_THRESHOLD = 15 * 1024 * 1024 @@ -61,17 +61,17 @@ def process_directory(base_dir: str, rel_path: str): # 若是 README,则已处理过;否则纳入链接 if item not in README_CANDIDATES: ext = item.split(".")[-1].lower() if "." in item else "" - file_size = os.path.getsize(full_item_path) + # file_size = os.path.getsize(full_item_path) # blob 类文件链接 if ext in BLOB_EXTS: file_url = BLOB_URL_PREFIX + quote(f"{rel_path}/{item}") else: # 大文件链接 - if file_size > LARGE_THRESHOLD: - file_url = LARGE_URL_PREFIX + quote(f"{rel_path}/{item}") - else: - file_url = BIN_URL_PREFIX + quote(f"{rel_path}/{item}") + # if file_size > LARGE_THRESHOLD: + # file_url = LARGE_URL_PREFIX + quote(f"{rel_path}/{item}") + # else: + file_url = BIN_URL_PREFIX + quote(f"{rel_path}/{item}") file_links.append((item, file_url)) else: