forked from gfdgd_xi/spark-store-download
第一版本
This commit is contained in:
commit
350a32dc7b
|
@ -0,0 +1,3 @@
|
||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/spark-download.iml" filepath="$PROJECT_DIR$/.idea/spark-download.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,195 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
##########################################
|
||||||
|
# 星火应用商店下载量统计功能
|
||||||
|
# 作者:gfdgd xi、为什么您不喜欢熊出没和阿布
|
||||||
|
# 版本:1.0
|
||||||
|
# 更新时间:2022年07月01日(期末考试完了!!!)
|
||||||
|
# 接口详解:
|
||||||
|
# 1、使用 http post 操作,post 为:
|
||||||
|
# {"spk": "SPK链接"}
|
||||||
|
# 暂不支持包名以及 get 操作
|
||||||
|
##########################################
|
||||||
|
###############
|
||||||
|
# 引入库
|
||||||
|
###############
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
import traceback
|
||||||
|
import urllib.parse
|
||||||
|
import tornado.web
|
||||||
|
import tornado.ioloop
|
||||||
|
|
||||||
|
###############
|
||||||
|
# 参数设置
|
||||||
|
###############
|
||||||
|
# deb 仓库本地地址
|
||||||
|
packagePath = "/home/gfdgd_xi/Desktop/spark-download"
|
||||||
|
# 端口号
|
||||||
|
post = 8000
|
||||||
|
# 启动/关闭防单 IP 高刷功能
|
||||||
|
stopConnectOften = True
|
||||||
|
# IP 黑名单清理时间(永不清理可以设置为负数)
|
||||||
|
cleanTimeSet = 60 * 60
|
||||||
|
# 最大访问值
|
||||||
|
max_post = 30
|
||||||
|
# 启用/关闭 IP 单一时间访问太大自动保存本地(未实现)
|
||||||
|
unableUseIpListSave = True
|
||||||
|
# IP 单一时间访问太大自动保存本地的值
|
||||||
|
unableUseIP = 100
|
||||||
|
# 调试模式(未实现)
|
||||||
|
debug = False
|
||||||
|
|
||||||
|
|
||||||
|
###############
|
||||||
|
# 非参数设置,请勿乱动
|
||||||
|
###############
|
||||||
|
# bug 数量记录
|
||||||
|
bug = 0
|
||||||
|
# 黑名单 IP
|
||||||
|
ip = {}
|
||||||
|
# 清理时间
|
||||||
|
cleanTime = 30
|
||||||
|
# 读取程序路径
|
||||||
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||||
|
# 黑名单写入次数
|
||||||
|
blackWriteTime = 0
|
||||||
|
# 版本
|
||||||
|
version = "1.0.0"
|
||||||
|
# 作者
|
||||||
|
celebrateUser = ["gfdgd xi", "为什么您不喜欢熊出没和阿布呢"]
|
||||||
|
|
||||||
|
###############
|
||||||
|
# 函数实现
|
||||||
|
###############
|
||||||
|
def Clean():
|
||||||
|
global cleanTime
|
||||||
|
global blackWriteTime
|
||||||
|
global unableUseIpListSave
|
||||||
|
cleanTime -= 1
|
||||||
|
if cleanTime == 0: # 到达 IP 黑名单清理时间
|
||||||
|
# 读取有没有调皮的 IP 访问次数爆炸
|
||||||
|
ipFile = open(f"{programPath}/ip.json", "r")
|
||||||
|
ipList = json.loads(ipFile.read())
|
||||||
|
ipFile.close()
|
||||||
|
if unableUseIpListSave:
|
||||||
|
black = False
|
||||||
|
for key, value in ip.items():
|
||||||
|
if value >= unableUseIP and not ip[key] < 0:
|
||||||
|
ipList.append(key)
|
||||||
|
black = True
|
||||||
|
if black:
|
||||||
|
ipFile = open(f"{programPath}/ip.json", "w")
|
||||||
|
ipFile.write(json.dumps(ipList))
|
||||||
|
ipFile.close()
|
||||||
|
blackWriteTime += 1
|
||||||
|
print(f"写入黑名单{blackWriteTime}次")
|
||||||
|
ip.clear()
|
||||||
|
for i in ipList:
|
||||||
|
ip[i] = -1
|
||||||
|
cleanTime = cleanTimeSet
|
||||||
|
time.sleep(1)
|
||||||
|
Clean()
|
||||||
|
|
||||||
|
class SPK:
|
||||||
|
def __init__(self, spkUrl, savePath):
|
||||||
|
self.spkUrl = spkUrl
|
||||||
|
package = urllib.parse.urlparse(spkUrl).path[1:]
|
||||||
|
self.package = package[package.index("/") + 1:]
|
||||||
|
self.savePath = savePath
|
||||||
|
|
||||||
|
def information(self):
|
||||||
|
appListFile = open(f"{self.savePath}/applist.json").read()
|
||||||
|
appList = json.loads(appListFile)
|
||||||
|
for i in appList:
|
||||||
|
if i["Pkgname"] == self.package:
|
||||||
|
return i
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
for i in ["chat", "development", "games", "image_graphics", "music", "network", "office", "others", "reading", "themes", "tools", "video"]:
|
||||||
|
path = f"{self.savePath}/store/{i}/{self.package}/download-times.txt"
|
||||||
|
floder = f"{self.savePath}/store/{i}/{self.package}/"
|
||||||
|
# 文件不存在的情况
|
||||||
|
if not os.path.exists(floder):
|
||||||
|
continue
|
||||||
|
# 有文件但却没下载量文件的情况
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mknod(path)
|
||||||
|
read = 0
|
||||||
|
else:
|
||||||
|
# 读取文件
|
||||||
|
file = open(path, "r")
|
||||||
|
read = file.read()
|
||||||
|
file.close()
|
||||||
|
# 写入文件
|
||||||
|
file = open(path, "w")
|
||||||
|
# 对文件异常值的判断
|
||||||
|
if read == "":
|
||||||
|
read = 0
|
||||||
|
else:
|
||||||
|
read = int(read)
|
||||||
|
file.write(str(read + 1))
|
||||||
|
file.close()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
class Save(tornado.web.RequestHandler):
|
||||||
|
def get(self):
|
||||||
|
self.write('{"ExitCode": 5, "Error": "访问方式错误"}')
|
||||||
|
|
||||||
|
def post(self):
|
||||||
|
if stopConnectOften:
|
||||||
|
if self.request.headers["Host"] in ip:
|
||||||
|
if ip[self.request.headers["Host"]] < 0:
|
||||||
|
self.write('{"ExitCode": 2, "Error": "此 IP 已经被永久封禁,无法继续"}')
|
||||||
|
return
|
||||||
|
ip[self.request.headers["Host"]] += 1
|
||||||
|
else:
|
||||||
|
ip[self.request.headers["Host"]] = 1
|
||||||
|
if ip[self.request.headers["Host"]] > max_post:
|
||||||
|
self.write('{"ExitCode": 1, "Error": "此IP地址超过最大访问次数,无法继续"}')
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
if not SPK(str(self.get_body_argument("spk")), packagePath).save():
|
||||||
|
self.write('{"ExitCode": 4, "Error": "没有找到指定的包"}')
|
||||||
|
return
|
||||||
|
self.write('{"ExitCode": 0, "Error": ""}')
|
||||||
|
except:
|
||||||
|
if debug:
|
||||||
|
self.write(json.dumps({"ExitCode": 6, "Error": traceback.format_exc()}))
|
||||||
|
else:
|
||||||
|
self.write('{"ExitCode": 6, "Error": "500 服务器错误"}')
|
||||||
|
global bug
|
||||||
|
bug += 1
|
||||||
|
print(f"#########第{bug}个错误,不影响程序继续运行##########")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
###############
|
||||||
|
# 启动事件
|
||||||
|
###############
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if "--help" in sys.argv:
|
||||||
|
print("帮助:")
|
||||||
|
print("--about 查看程序信息")
|
||||||
|
print("更多内容需要修改程序参数")
|
||||||
|
sys.exit()
|
||||||
|
if "--about" in sys.argv:
|
||||||
|
print(f"程序版本:{version}")
|
||||||
|
print(f"程序作者:{','.join(celebrateUser)}")
|
||||||
|
sys.exit()
|
||||||
|
# 读取黑名单 IP
|
||||||
|
ipFile = open(f"{programPath}/ip.json", "r")
|
||||||
|
for i in json.loads(ipFile.read()):
|
||||||
|
ip[i] = -1
|
||||||
|
ipFile.close()
|
||||||
|
# 启动黑名单清空(如果启用的话)
|
||||||
|
if stopConnectOften:
|
||||||
|
threading.Thread(target=Clean).start()
|
||||||
|
# 开启监听
|
||||||
|
app = tornado.web.Application([
|
||||||
|
(r"/", Save)
|
||||||
|
])
|
||||||
|
app.listen(post)
|
||||||
|
tornado.ioloop.IOLoop.current().start()
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"Name": "UEngine 运行器 1.6.2",
|
||||||
|
"Version": "1.6.2-1",
|
||||||
|
"Filename": "com.gitee.uengine.runner.spark_1.6.2-1_all.deb",
|
||||||
|
"Torrent_address": "com.gitee.uengine.runner.spark_1.6.2-1_all.deb.torrent",
|
||||||
|
"Pkgname": "com.gitee.uengine.runner.spark",
|
||||||
|
"Author": "gfdgd xi",
|
||||||
|
"Contributor": "gfdgd xi",
|
||||||
|
"Website": "https://gitee.com/gfdgd-xi/uengine-runner",
|
||||||
|
"Update": "2022-06-22 11:35:20",
|
||||||
|
"Size": "1.23 MB",
|
||||||
|
"More": "此为UOS打包标准,支持从老标准升级!!! \n\n※1、优化了 UEngine 运行器的英语翻译 \n※2、新增加了可以打开或关闭第三方应用安装的功能(使用此功能后在UEngine里可以使用默认的APK安装程序安装应用,此操作需要使用程序的Adb补丁) \n※3、新增加了 UEngine 的 Ubuntu 安装程序 \n※4、双包合一,只保留了UOS打包标准,可以从旧标准无缝升级(推荐使用本程序的升级程序进行升级) \n5、修复了本程序在 Ubuntu 上安装和卸载报错而无法继续的问题 \n6、优化帮助/关于窗口在高分辨率电脑上显示不全的问题",
|
||||||
|
"Tags": "community;ubuntu;deepin;uos",
|
||||||
|
"img_urls": "[\"https://examine-spark.oss-cn-shanghai.aliyuncs.com/images/2022/06/22/5664f9c0-f1dc-11ec-9089-b7b4a6ff218e.png\"]",
|
||||||
|
"icons": "https://examine-spark.oss-cn-shanghai.aliyuncs.com/icons/2022/06/22/514aabb0-f1dc-11ec-9089-b7b4a6ff218e.png"
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
233
|
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | Size: 237 KiB |
Binary file not shown.
After Width: | Height: | Size: 215 KiB |
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
Binary file not shown.
After Width: | Height: | Size: 198 KiB |
Binary file not shown.
After Width: | Height: | Size: 195 KiB |
Loading…
Reference in New Issue