Skip to content

Commit

Permalink
add upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed Nov 28, 2024
1 parent 672df26 commit 069560c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generate-bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
else:
os.system("pip install rtoml")

os.system("python3 -m pip install pyyaml install-jdk tqdm psutil requests imageio pygithub rtoml elevate nuitka ordered-set")
os.system("python3 -m pip install pyyaml install-jdk tqdm psutil requests imageio pygithub rtoml elevate colorama nuitka ordered-set")

if os.path.exists("dist"):
shutil.rmtree("dist")
Expand Down
61 changes: 61 additions & 0 deletions src/resource-upload.py
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()


0 comments on commit 069560c

Please sign in to comment.