支持读取历史记录
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user