-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
672df26
commit 069560c
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import os.path | ||
|
||
import requests | ||
|
||
from utils import * | ||
api_url="https://rscdn.imc.rip" | ||
|
||
script_license() | ||
|
||
def get_zip_path(): | ||
if os.path.exists("plugins/ItemsAdder/output/generated.zip"): | ||
return "plugins/ItemsAdder/output/generated.zip" | ||
if os.path.exists("ItemsAdder/output/generated.zip"): | ||
return "ItemsAdder/output/generated.zip" | ||
if os.path.exists("output/generated.zip"): | ||
return "output/generated.zip" | ||
if os.path.exists("generated.zip"): | ||
return "generated.zip" | ||
return None | ||
|
||
def main(): | ||
print("欢迎使用笨蛋文档资源包分发") | ||
key = input("请输入 AuthKey:") | ||
secret = input("请输入 AuthSecret:") | ||
path = get_zip_path() | ||
if path is None: | ||
path = input("输入资源包路径:") | ||
if not os.path.exists(path): | ||
print(f"{path} 不存在") | ||
else: | ||
print(f"检测到资源包: {path}") | ||
|
||
print("开始上传") | ||
file={ | ||
"file":open(path,"rb") | ||
} | ||
res=requests.post(f"{api_url}/upload?api-key={key}", | ||
files=file, | ||
headers={"Auth-Secret":secret}) | ||
if res.status_code==422: | ||
print("验证失败") | ||
return | ||
if res.status_code==401: | ||
print("验证失败") | ||
return | ||
if res.status_code==400: | ||
print("超过最大文件体积") | ||
return | ||
if res.status_code==500: | ||
print("服务器故障") | ||
return | ||
|
||
print("上传成功") | ||
print(f"下载链接:{api_url}/download?api-key={key}") | ||
if ask("是否进行资源包预热(加快首次下载)"): | ||
requests.get(f"{api_url}/download?api-key={key}") | ||
print("预热成功") | ||
|
||
main() | ||
|
||
|