uengine-runner-list/upload.py

117 lines
4.3 KiB
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
import os
import sys
import json
import datetime
import urllib.parse
#datetime.datetime.now().year
urlss = False
if sys.argv[1] == "":
sys.argv[1] = input("地址>").strip()
fileName = os.path.basename(sys.argv[1])
fileMainName = os.path.splitext(fileName)[0]
try:
about = sys.argv[3].replace("\\n", "\n")
if about == "u":
about = sys.argv[1]
urlss = True
fileName = urllib.parse.urlparse(sys.argv[1]).netloc
fileMainName = urllib.parse.urlparse(sys.argv[1]).netloc
elif not "<" in about and not "Visit: " in about:
about = f"<pre>{about}</pre>"
except:
about = None
if "http:" in sys.argv[1] or "https://" in sys.argv[1]:
url = sys.argv[1]
else:
url = f"https://code.gitlink.org.cn/gfdgd_xi/program-library-android/raw/branch/master/{fileName}?gfdgd_xi=gfdgd_xi"
os.system(f"cp -rv '{sys.argv[1]}' ../program-library-android")
if os.path.splitext(fileName)[1] == ".deb":
command = f'''#!/usr/bin/env uengine-runner-auto-install-bash
# 使用 UEngine 运行器(原 Wine 运行器)的语言解析器
##########################################################################################
# 作者gfdgd xi
# 更新时间:{datetime.datetime.now().year}{datetime.datetime.now().month}{datetime.datetime.now().day}
##########################################################################################
# 用于判断是否为 bash 解释器
if [[ 1 == 2 ]]; then
download "{url}" /tmp "{fileName}"
pkexec apt install "/tmp/{fileName}" -y
info 提示 安装成功!
exit
fi
download "{url}" /tmp "{fileName}"
if [[ -f "/tmp/{fileName}" ]]; then
# Nothing
echo Download Done!
else
error 错误 文件下载失败!
exit
fi
pkexec apt install "/tmp/{fileName}" -y
if [[ $? == 0 ]]; then
info 提示 安装成功!
else
error 错误 安装失败!
fi
rm -rfv "/tmp/{fileName}"
'''
else:
runProgramCommand = "installapk"
if os.path.splitext(fileName)[1] == ".msi":
runProgramCommand = "installmsi"
command = f'''#!/usr/bin/env uengine-runner-auto-install-bash
# 使用 UEngine 运行器(原 Wine 运行器)的语言解析器
##########################################################################################
# 作者gfdgd xi
# 更新时间:{datetime.datetime.now().year}{datetime.datetime.now().month}{datetime.datetime.now().day}
##########################################################################################
# 用于判断是否为 bash 解释器
if [[ 1 == 2 ]]; then
# 保持对旧版本的兼容
bash rm "/tmp/{fileName}"
fi
rm "/tmp/{fileName}"
download "{url}" /tmp "{fileName}"
{runProgramCommand} "/tmp/{fileName}"
info 提示 安装完成!
rm -rfv "/tmp/{fileName}"
'''
if urlss:
command = f'''#!/usr/bin/env uengine-runner-auto-install-bash
# 使用 UEngine 运行器(原 Wine 运行器)的语言解析器
##########################################################################################
# 作者gfdgd xi
# 更新时间:{datetime.datetime.now().year}{datetime.datetime.now().month}{datetime.datetime.now().day}
##########################################################################################
# 用于判断是否为 bash 解释器
if [[ 1 == 2 ]]; then
# 保持对旧版本的兼容
bash xdg-open '{sys.argv[1]}'
fi
xdg-open '{sys.argv[1]}' '''
with open("auto/list.json", "r") as file:
lists = json.loads(file.read())
#lists = []
lists.insert(1, [f"{sys.argv[2]}", f"{fileMainName}.sh"])
with open("auto/list.json", "w") as file:
file.write(json.dumps(lists, ensure_ascii=False, indent=4))
with open(f"auto/{fileMainName}.sh", "w") as file:
file.write(command)
if about != None:
with open(f"auto/information/{fileMainName}.sh.txt", "w") as file:
file.write(about)
#print(command)
#exit()
os.system("cd auto; git add .")
os.system(f"cd auto; git commit -m '新增程序 {sys.argv[2]}'")
os.system("cd auto; git push")
os.system("cd ../program-library-android; git add .")
os.system(f"cd ../program-library-android; git commit -m '新增程序 {sys.argv[2]}'")
os.system("cd ../program-library-android; git push")
os.system("git add .")
os.system(f"git commit -m '新增程序 {sys.argv[2]}'")
os.system("git push")
os.system("bash ../wine-runner-list-upload.sh")
print("\n")