kindle manager

This commit is contained in:
douboer
2020-06-30 12:06:07 +08:00
parent 6aed9982f6
commit 338e83ab25
27 changed files with 82164 additions and 77 deletions

View File

@@ -46,7 +46,7 @@ infos_temp = """<table border="0">
</td>
<td style="border-left:1px solid lightgray;"> </td>
<td width=100> </td>
<td> <img style="max-width:220px;" src="/Users/mark/kman/downimg/{img}" > </td>
<td> <img style="max-width:220px;" src="./downimg/{img}" > </td>
</tr>
</table>"""
@@ -81,6 +81,7 @@ class kmanWindow(QMainWindow):
self.km = kMan()
self.spide = bookInfoSpide()
self.books_info = defaultdict(dict)
# initial check order:
# 1. backup file bk.data ->
# 2. kindle(My Clippings.txt) ->
@@ -104,11 +105,16 @@ class kmanWindow(QMainWindow):
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data)
#self.filter_list = self.km.filter_words(self.words_data)
self.create_books_info_daemon()
###############################################################
## move to create_books_info_daemon
###############################################################
# initial books information which grab from douban or amazon
# if the information exist in backup file, initial with this file,
# and grap new book's information from douban
# else grap all book information from douban
self.books_info = defaultdict(dict)
"""
try:
if os.path.exists(BACKUPINFOFN):
self.books_info = self.km.json2dict(BACKUPINFOFN)
@@ -126,6 +132,7 @@ class kmanWindow(QMainWindow):
print(e)
finally:
pass
"""
self.fill_treeview()
self.refresh_ui_component(comp=1)
@@ -476,6 +483,8 @@ class kmanWindow(QMainWindow):
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data)
self.filter_wordlist = self.km.filter_words(self.words_data)
#self.create_books_info_daemon()
self.fill_treeview()
self.refresh_ui_component(1)
@@ -489,6 +498,8 @@ class kmanWindow(QMainWindow):
self.books_data = self.km.import_clips(fn)
[self.filter_books, self.filter_list] = self.km.filter_clips(self.books_data)
#self.create_books_info_daemon()
self.fill_treeview()
self.refresh_ui_component(1)
@@ -700,6 +711,33 @@ class kmanWindow(QMainWindow):
if bks_info: return self.books_info.update(bks_info)
def create_books_info_daemon(self):
# initial books information which grab from douban or amazon
# if the information exist in backup file, initial with this file,
# and grap new book's information from douban
# else grap all book information from douban
try:
if os.path.exists(BACKUPINFOFN):
self.books_info = self.km.json2dict(BACKUPINFOFN)
increase_book_list = self.check_increase_books(self.books_data, self.books_info)
if len(increase_book_list) > 0:
trd = threading.Thread(target=self.grab_books_info, args=(increase_book_list,))
trd.setDaemon(True)
trd.start()
else:
booklist = list(self.books_data.keys())
trd = threading.Thread(target=self.grab_books_info, args=(book_list,))
trd.setDaemon(True)
trd.start()
except Exception as e:
print(e)
finally:
self.fill_treeview()
self.refresh_ui_component(1)
pass
# thanks Martin Fitzpatrick ^_^
# https://www.learnpyqt.com/courses/model-views/qtableview-modelviews-numpy-pandas/
class nTableModel(QAbstractTableModel):