From 8b2fc97f4e16c7e93e93aa6ffd9f455309b7fca7 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 9 Mar 2024 21:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AF=BB=E5=8F=96=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- export.py | 8 ++++++-- novelCiwei.py | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/export.py b/export.py index dfca0e9..24d3aa2 100644 --- a/export.py +++ b/export.py @@ -134,8 +134,12 @@ def export(ncw: NovelCiwei, db: CwmDb, cfg: Config, bn: BooksNew): book = json.loads(choice(shelfs[shelf])['book_info']) data += f"\n书架内有 {book['book_name']} - {book['author_name']}" return data - shelf = ask_choice(cfg, [i for i in shelfs.keys()], '请选择书架:', show_shelf) - books = [json.loads(b['book_info']) for b in shelfs[shelf]] + shelf = ask_choice(cfg, [i for i in shelfs.keys()], '请选择书架:', show_shelf, + [('r', '阅读历史', 'readhistory')]) + if shelf == 'readhistory': + books = [json.loads(b['book_info']) for b in ncw.get_read_history()] + else: + books = [json.loads(b['book_info']) for b in shelfs[shelf]] book = ask_choice(cfg, books, '请选择书:', lambda b: f"{b['book_name']} - {b['author_name']}") # noqa: E501 book_id = int(book['book_id']) if action == 'book': diff --git a/novelCiwei.py b/novelCiwei.py index 09dd4be..4dce68a 100644 --- a/novelCiwei.py +++ b/novelCiwei.py @@ -42,3 +42,9 @@ class NovelCiwei: 'SELECT * FROM catalog1 WHERE chapter_id = ?;', [str(chapter_id)]) cur.row_factory = sqlite3.Row return cur.fetchone() + + def get_read_history(self): + cur = self._db.execute( + 'SELECT * FROM read_history ORDER BY readtime DESC;') + cur.row_factory = sqlite3.Row + return cur.fetchall()