This commit is contained in:
2024-03-09 21:18:02 +08:00
parent 8b2fc97f4e
commit 3888030eec
2 changed files with 11 additions and 0 deletions

View File

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

View File

@@ -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