feat(p3): add discovery, telegram notifications, and one-click favorites

Implement WBI video search with legacy fallback, classification scoring, candidate pool, permanent seen-aid dedupe, blacklist filtering, and batched Telegram notifications. Add write client for fav deal/sort, target-folder selection, insertion position calculation, read-back verification, fav_action locking, retry on failure, ignore and blacklist actions. Wire discovery, candidate cleanup, Telegram long polling, and new discover/candidates CLI commands into the scheduler. Add migration v3 for candidate duration and index stats.
This commit is contained in:
kairee committed 2026-10-31 21:23:12 +08:00
1 parent 6a21b5d905
commit d971e718e9
31 files changed
+2886 -55

No files matched your search

+11 -7
View File
@@ -37,18 +37,22 @@ def test_fresh_and_idempotent():
conn = sqlite3.connect(Path(tmp) / "app.db")
try:
applied = run_migrations(conn)
assert applied == [1, 2]
assert current_version(conn) == 2
assert applied == [1, 2, 3]
assert current_version(conn) == 3
assert EXPECTED_TABLES <= table_names(conn)
assert "schema_version" in table_names(conn)
columns = {
row[1] for row in conn.execute("PRAGMA table_info(folder_resource)")
}
assert "fav_time" in columns
candidate_columns = {
row[1] for row in conn.execute("PRAGMA table_info(candidate)")
}
assert {"duration", "play", "like", "favorite", "danmaku", "review"} <= candidate_columns
# 再跑一次不应重复应用
assert run_migrations(conn) == []
row = conn.execute("SELECT COUNT(*) FROM schema_version").fetchone()
assert row[0] == 2
assert row[0] == 3
finally:
conn.close()
@@ -63,15 +67,15 @@ def test_backup_before_upgrade():
conn.execute("INSERT INTO kv(k, v) VALUES ('hello', 'world')")
conn.commit()
v3 = Migration(3, "add probe", ("CREATE TABLE probe (id INTEGER PRIMARY KEY)",))
v4 = Migration(4, "add probe", ("CREATE TABLE probe (id INTEGER PRIMARY KEY)",))
applied = run_migrations(
conn,
backup_dir=backup_dir,
now=1_800_000_000,
migrations=MIGRATIONS + (v3,),
migrations=MIGRATIONS + (v4,),
)
assert applied == [3]
backups = list(backup_dir.glob("app-pre-v2-*.db"))
assert applied == [4]
backups = list(backup_dir.glob("app-pre-v3-*.db"))
assert len(backups) == 1
check = sqlite3.connect(backups[0])
try: