67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
import json, http.cookiejar, urllib.request, sys
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
base = "https://dylive.nomadro.com"
|
|
cj = http.cookiejar.CookieJar()
|
|
op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
|
|
data = json.dumps({"username": "hackrobot", "password": "Xiao4669805@"}).encode()
|
|
op.open(
|
|
urllib.request.Request(
|
|
base + "/api/auth/login",
|
|
data=data,
|
|
method="POST",
|
|
headers={"Content-Type": "application/json"},
|
|
),
|
|
timeout=30,
|
|
)
|
|
with op.open(urllib.request.Request(base + "/api/shorts/status"), timeout=45) as r:
|
|
st = json.loads(r.read().decode())
|
|
board = st.get("board") or {}
|
|
print(
|
|
"enabled", st.get("enabled"),
|
|
"running", st.get("running"),
|
|
"busy", st.get("busy"),
|
|
"live", st.get("douyin_live_count"),
|
|
"err", st.get("last_error"),
|
|
)
|
|
print(
|
|
"gap", board.get("total_gap"),
|
|
"min_unmet", board.get("min_unmet"),
|
|
"min_unmet_channels", board.get("min_unmet_channels"),
|
|
"sec_left", board.get("seconds_left"),
|
|
)
|
|
print("forecast", json.dumps(board.get("quota_forecast"), ensure_ascii=False))
|
|
with op.open(urllib.request.Request(base + "/api/shorts/schedule"), timeout=45) as r:
|
|
b = json.loads(r.read().decode())
|
|
print("schedule gap", b.get("total_gap"), "min_unmet", b.get("min_unmet"), "sec", b.get("seconds_left"))
|
|
print("forecast2", json.dumps(b.get("quota_forecast"), ensure_ascii=False))
|
|
chans = [c for c in (b.get("channels") or []) if c.get("enabled")]
|
|
under = [c for c in chans if not c.get("min_met")]
|
|
print("enabled", len(chans), "under", len(under))
|
|
pipe_full = 0
|
|
for c in under:
|
|
if int(c.get("pipeline") or 0) >= int(c.get("daily_max") or 9):
|
|
pipe_full += 1
|
|
print("under_pipeline_full", pipe_full)
|
|
for c in under[:10]:
|
|
print(
|
|
c.get("name"),
|
|
"up", c.get("uploaded"),
|
|
"pe", c.get("pending"),
|
|
"sch", c.get("scheduled"),
|
|
"pipe", c.get("pipeline"),
|
|
"gap", c.get("gap"),
|
|
)
|
|
# job status breakdown via jobs API
|
|
with op.open(urllib.request.Request(base + "/api/shorts/jobs?limit=1"), timeout=30) as r:
|
|
j = json.loads(r.read().decode())
|
|
print("jobs_total_hint", j.get("total"))
|
|
# fill once dry?
|
|
req = urllib.request.Request(base + "/api/shorts/fill-quota", data=b"{}", method="POST", headers={"Content-Type": "application/json"})
|
|
try:
|
|
with op.open(req, timeout=90) as r:
|
|
fr = json.loads(r.read().decode())
|
|
print("fill", json.dumps(fr, ensure_ascii=False)[:800])
|
|
except Exception as ex:
|
|
print("fill_err", ex)
|