feat(reader): autonomous Wikipedia import and reading with media, tables and settings

This commit is contained in:
2026-10-07 09:47:33 +03:00
parent 52db766b23
commit dee9b8d10b
9 changed files with 1659 additions and 24 deletions
+6
View File
@@ -79,12 +79,18 @@ def _migrate(conn: sqlite3.Connection):
current_chapter INTEGER DEFAULT 0,
current_position REAL DEFAULT 0,
total_words INTEGER DEFAULT 0,
cover_url TEXT DEFAULT '',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
""")
# Safe migration: ensure cover_url column exists in books
books_cols = {row[1] for row in conn.execute("PRAGMA table_info(books)").fetchall()}
if "cover_url" not in books_cols:
conn.execute("ALTER TABLE books ADD COLUMN cover_url TEXT DEFAULT ''")
# --- Deduplicate vocabulary_cards (case-insensitive) and enforce UNIQUE index ---
dup_rows = conn.execute("""
SELECT user_id, lower(trim(term)) as clean_term, COUNT(*) as cnt