From 3888030eec36f2695a6ca295bd3c7a2a50cfa7f2 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 9 Mar 2024 21:18:02 +0800 Subject: [PATCH] Update --- export.py | 4 ++++ novelCiwei.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/export.py b/export.py index 24d3aa2..b2f2eaa 100644 --- a/export.py +++ b/export.py @@ -55,6 +55,10 @@ def export_chapter(ncw: NovelCiwei, db: CwmDb, cfg: Config, bn: BooksNew, def export_book(ncw: NovelCiwei, db: CwmDb, cfg: Config, bn: BooksNew, book_id: int): book = ncw.get_book_in_shelf(book_id) + if book is None: + book = ncw.get_book_in_readhistory(book_id) + if book is None: + raise ValueError('The book is not found.') if cfg.export_txt: txt_filename = cfg.get_export_book(book, 'txt') d = dirname(txt_filename) diff --git a/novelCiwei.py b/novelCiwei.py index 4dce68a..fd23b7e 100644 --- a/novelCiwei.py +++ b/novelCiwei.py @@ -13,6 +13,13 @@ class NovelCiwei: for i in cur: return json.loads(i[0]) + def get_book_in_readhistory(self, book_id: int): + cur = self._db.execute( + 'SELECT book_info FROM read_history WHERE book_id = ?;', + [str(book_id)]) + for i in cur: + return json.loads(i[0]) + def get_books(self): cur = self._db.execute('SELECT * FROM shelf_book_info;') cur.row_factory = sqlite3.Row