Skip to content

Commit

Permalink
fix(dl): fix data length and group image numbers
Browse files Browse the repository at this point in the history
- 修复 可能的下载参数过长导致的无法下载问题
- 修复 数量超过 9 张的组图下载序号问题
  • Loading branch information
txperl committed Apr 10, 2022
1 parent ac943e2 commit b4b6884
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/lib/core/biu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@interRoot.bind("biu", "LIB_CORE")
class CoreBiu(interRoot):
def __init__(self):
self.ver = 205010
self.ver = 205020
self.place = "local"
self.sysPlc = platform.system()
self.api_route = "direct"
Expand Down
12 changes: 6 additions & 6 deletions app/lib/static/arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
@interRoot.bind("arg", "LIB_STATIC")
class static_arg(object):
@staticmethod
def getArgs(method, li):
def getArgs(method, li, way="GET"):
rst = {"ops": {"method": method}, "fun": {}}
data = request.args if way == "GET" else request.form
for x in li:
c = x.split("=")
group = "fun"
if c[0][:1] == "&":
group = "ops"
c[0] = c[0][1:]
if not request.args.get(c[0]):
if len(c) == 2:
rst[group][c[0]] = c[1]
else:
if not data.get(c[0]):
if len(c) != 2:
raise AttributeError("missing parameters: %s" % c[0])
rst[group][c[0]] = c[1]
else:
rst[group][c[0]] = request.args.get(c[0])
rst[group][c[0]] = data.get(c[0])
return rst

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions app/plugin/do/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ def __init__(self):

def run(self, cmd):
try:
args = self.STATIC.arg.getArgs("dl", ["kt", "workID=0", "data=0"])
args = self.STATIC.arg.getArgs("dl", ["kt", "workID=none", "data=none"], "POST")
except:
return {"code": 0, "msg": "missing parameters"}

if args["fun"]["workID"] == 0 and args["fun"]["data"] == 0:
if args["fun"]["workID"] == "none" and args["fun"]["data"] == "none":
return {"code": 0, "msg": "missing parameters"}

return {
"code": self.code,
"msg": {
"way": "do",
"args": args,
"rst": self.dl(args["ops"].copy(), args["fun"].copy()),
"rst": self.dl(args["ops"], args["fun"].copy()),
},
}

def dl(self, opsArg, funArg):
if funArg["data"] == 0:
if funArg["data"] == "none":
r = self.CORE.biu.api.illust_detail(funArg["workID"])
if "illust" not in r:
self.code = 0
Expand Down Expand Up @@ -72,7 +72,7 @@ def dl(self, opsArg, funArg):
file_type = "file"
url_hash = None
cache_name = None
urls = sorted([x["image_urls"]["original"] for x in r["meta_pages"]])
urls = [x["image_urls"]["original"] for x in r["meta_pages"]]
if self.CORE.biu.sets["biu"]["download"]["autoArchive"]:
extra = image_save_name + "/"
file_type = "folder"
Expand Down
24 changes: 17 additions & 7 deletions usr/static/multiverse/assets/js/biu/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,26 @@ function doFollow(id, action = 'add') {
});
}

function doDownloadPic(kt, workID = 0, idx = -1) {
function doDownloadPic(kt, workID = "none", idx = -1) {
if (downloadList.hasOwnProperty(workID))
return;
let data;
if (idx !== -1)
data = JSON.stringify(tmpPageData['rst']['data'][idx]['all']);
else
data = 0;
if (workID === "none" && idx === -1)
return;
let data = "none";
if (idx !== -1 && tmpPageData["rst"]["data"][idx]) {
const temp = tmpPageData["rst"]["data"][idx]["all"];
data = JSON.stringify({
id: temp.id,
type: temp.type,
title: temp.title,
create_date: temp.create_date,
user: temp.user,
meta_single_page: temp.meta_single_page,
meta_pages: temp.meta_pages
});
}
$.ajax({
type: "GET",
type: "POST",
async: true,
url: "api/biu/do/dl/",
data: {
Expand Down
2 changes: 1 addition & 1 deletion usr/templates/multiverse/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h2>属性</h2>
<input id="filtersImageHeight" class="tooltip" placeholder="高度范围" autocomplete="off"
title="图片的高度范围,如 500:600 或 500: 或 :600">
<input id="filtersImageWidthHeightRate" class="tooltip" placeholder="宽高比范围"
autocomplete="off" title="图片的宽高比范围,以 / 表示比例,以 : 表示范围,如 1/1:4/3 或 1/1: 或 :4/3">
autocomplete="off" title="图片的宽高比范围,以 / 表示比,以 : 表示范围,如 1/1:4/3 或 1/1: 或 :4/3">
</div>
<div>
<input id="filtersImageTime" class="tooltip" placeholder="时间范围" autocomplete="off"
Expand Down

0 comments on commit b4b6884

Please sign in to comment.