修改HACS源代码使用CDN快速下载集成
0
# 显示原始下载地址
print(url)
# 源文件
if "https://raw.githubusercontent.com" in url:
arr = url.replace("https://raw.githubusercontent.com/", "").split("/")
arr[1] = arr[1] + "@" + arr[2]
arr[2] = ""
_list = ["https://cdn.jsdelivr.net/gh"]
for item in arr:
if item != "":
_list.append(item)
url = "/".join(_list)
_LOGGER.debug("下载链接:%s", url)
# 发布文件
if "https://github.com/" in url and "/releases/download/" in url:
url = url.replace('https://github.com/', 'https://hub.fastgit.org/')
# 修改后的下载地址
print(url)