This commit is contained in:
1 parent
2f39ee11df
commit
da30de0318
16 files changed
+142
-22
No files matched your search
+31
-1
@@ -8,6 +8,7 @@ Binds to 127.0.0.1 by default: no auth, do not expose it to the internet.
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
@@ -705,6 +706,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._json({"cancelled": JOBS.cancel()})
|
||||
elif path == "/api/job/retry":
|
||||
self._json({"started": JOBS.retry()})
|
||||
elif path == "/api/hltb":
|
||||
self._start_hltb(self._body())
|
||||
elif path == "/api/refresh":
|
||||
body = self._body()
|
||||
mode = body.get("mode", "incremental")
|
||||
@@ -984,13 +987,20 @@ class Handler(BaseHTTPRequestHandler):
|
||||
WHERE COALESCE(favorite,0)=1 OR COALESCE(rating,0)>=8)
|
||||
+ (SELECT COUNT(*) FROM reco_feedback) AS c
|
||||
""").fetchone()["c"]
|
||||
hltb_checked = con.execute(
|
||||
"""SELECT COUNT(*) FROM games WHERE LOWER(type)='game'
|
||||
AND hltb_checked_at IS NOT NULL""").fetchone()[0]
|
||||
hltb_matched = con.execute(
|
||||
"""SELECT COUNT(*) FROM games WHERE LOWER(type)='game'
|
||||
AND hltb_match = 1""").fetchone()[0]
|
||||
self._json({
|
||||
"total": total, "installed": installed, "played": played,
|
||||
"hours": round(minutes / 60), "cached": cached, "missing": missing,
|
||||
"pending": max(0, total - cached - missing),
|
||||
"translated": translated, "translate_pending": translate_pending,
|
||||
"genres": genres, "tags": tags, "statuses": statuses,
|
||||
"signals": signals,
|
||||
"signals": signals, "hltb_checked": hltb_checked,
|
||||
"hltb_matched": hltb_matched,
|
||||
})
|
||||
finally:
|
||||
con.close()
|
||||
@@ -1478,6 +1488,26 @@ class Handler(BaseHTTPRequestHandler):
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
def _start_hltb(self, body):
|
||||
if importlib.util.find_spec("howlongtobeatpy") is None:
|
||||
self._error(400, "howlongtobeatpy не установлен: pip install -r requirements-hltb.txt")
|
||||
return
|
||||
try:
|
||||
limit = max(1, min(1000, int(body.get("limit", 200))))
|
||||
except (TypeError, ValueError):
|
||||
self._error(400, "invalid limit")
|
||||
return
|
||||
script = os.path.join(BASE, "tools", "fetch_hltb.py")
|
||||
args = [script, "--limit", str(limit)]
|
||||
if body.get("refresh"):
|
||||
args.append("--refresh")
|
||||
if body.get("retry_missed"):
|
||||
args.append("--retry-missed")
|
||||
if not JOBS.start("hltb", args):
|
||||
self._error(409, "another job is running")
|
||||
return
|
||||
self._json({"started": True, "limit": limit})
|
||||
|
||||
def _missing_ids(self, limit, retry_missing=False):
|
||||
limit = int(limit)
|
||||
con = connect()
|
||||
|
||||
Reference in new issue
Block a user