auto download fix

This commit is contained in:
2026-04-03 17:15:25 +09:00
parent 0e5a9fccab
commit a3ce380e33
2 changed files with 35 additions and 11 deletions
+31 -10
View File
@@ -503,6 +503,7 @@ class LogicLinkkf(object):
return LogicLinkkf.current_data return LogicLinkkf.current_data
else: else:
ret["ret"] = False ret["ret"] = False
ret["data"] = whitelist_programs
ret["log"] = "No current data!!" ret["log"] = "No current data!!"
except Exception as e: except Exception as e:
logger.error("Exception:%s", e) logger.error("Exception:%s", e)
@@ -551,22 +552,35 @@ class LogicLinkkf(object):
logger.debug(f"args: {args}") logger.debug(f"args: {args}")
try: try:
if len(args) == 0: if len(args) == 0 or args[0] in [None, ""]:
code = str(LogicLinkkf.current_data["code"]) if LogicLinkkf.current_data is None:
raise Exception("No current data")
code = str(LogicLinkkf.current_data["code"]).strip()
return_current_data = True
else: else:
# code = str(args[0]) payload = args[0]
code = str(args[0]["data_code"]) return_current_data = False
if isinstance(payload, dict):
code = str(
payload.get("data_code")
or payload.get("code")
or payload.get("program_code")
or ""
).strip()
else:
code = str(payload).strip()
whitelist_program = ModelSetting.get("whitelist_program") if code == "":
raise Exception("No code")
whitelist_program = ModelSetting.get("whitelist_program") or ""
whitelist_programs = [ whitelist_programs = [
str(x.strip().replace(" ", "")) str(x.strip().replace(" ", ""))
for x in whitelist_program.replace("\n", ",").split(",") for x in whitelist_program.replace("\n", ",").split(",")
] ]
whitelist_programs = [x for x in whitelist_programs if x != ""]
if code not in whitelist_programs: if code not in whitelist_programs:
whitelist_programs.append(code) whitelist_programs.append(code)
whitelist_programs = filter(
lambda x: x != "", whitelist_programs
) # remove blank code
whitelist_program = ",".join(whitelist_programs) whitelist_program = ",".join(whitelist_programs)
entity = ( entity = (
db.session.query(ModelSetting) db.session.query(ModelSetting)
@@ -574,11 +588,18 @@ class LogicLinkkf(object):
.with_for_update() .with_for_update()
.first() .first()
) )
entity.value = whitelist_program if entity is None:
entity = ModelSetting("whitelist_program", whitelist_program)
db.session.add(entity)
else:
entity.value = whitelist_program
db.session.commit() db.session.commit()
ret["ret"] = True ret["ret"] = True
ret["code"] = code ret["code"] = code
if len(args) == 0: ret["data"] = whitelist_programs
if return_current_data:
LogicLinkkf.current_data["ret"] = True
LogicLinkkf.current_data["whitelist_program"] = whitelist_program
return LogicLinkkf.current_data return LogicLinkkf.current_data
else: else:
return ret return ret
+4 -1
View File
@@ -170,7 +170,10 @@ class ModuleBasic(PluginModuleBase):
return jsonify(LogicLinkkf.apply_new_season(req.form["new_season"])) return jsonify(LogicLinkkf.apply_new_season(req.form["new_season"]))
if sub == "add_whitelist": if sub == "add_whitelist":
payload = req.get_json() payload = req.get_json()
ret = LogicLinkkf.add_whitelist(payload if payload is not None else None) if payload is None:
ret = LogicLinkkf.add_whitelist()
else:
ret = LogicLinkkf.add_whitelist(payload)
return jsonify(ret) return jsonify(ret)
if sub == "add_queue": if sub == "add_queue":
code = req.form["code"] code = req.form["code"]