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()