kindle manager
This commit is contained in:
23
kman.py
23
kman.py
@@ -59,7 +59,8 @@ SYS = 'WIN' if platform.system()=='Windows' else \
|
|||||||
# some constants
|
# some constants
|
||||||
LASTLINE = '=========='
|
LASTLINE = '=========='
|
||||||
NTPREF = '--CG注:'
|
NTPREF = '--CG注:'
|
||||||
CLIPPATH = './My Clippings.txt' # /Volumes/Kindle/documents/My\ Clippings.txt
|
#CLIPPATH = './My Clippings.txt' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||||
|
CLIPPATH = './tclip.txt'
|
||||||
OUTPREF = './clip'
|
OUTPREF = './clip'
|
||||||
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
||||||
LOG2FILE = 1 # 0 - to stdio; 1 - to file
|
LOG2FILE = 1 # 0 - to stdio; 1 - to file
|
||||||
@@ -368,13 +369,13 @@ def json2dict(jf):
|
|||||||
d=json.load(f)
|
d=json.load(f)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
if __name__=='__main__':
|
def import_clips():
|
||||||
# 4 lines for each section seperated with '======='
|
# 4 lines for each section seperated with '======='
|
||||||
# so read 4 lines before '======='
|
# so read 4 lines before '======='
|
||||||
|
|
||||||
# loop to fill books dict
|
# loop to fill books dict
|
||||||
with open(CLIPPATH, 'r', encoding='utf8', errors='ignore') as f:
|
with open(CLIPPATH, 'r', encoding='utf8', errors='ignore') as f:
|
||||||
books = defaultdict(dict)
|
bks = defaultdict(dict)
|
||||||
secd = defaultdict(dict)
|
secd = defaultdict(dict)
|
||||||
sidx = 0
|
sidx = 0
|
||||||
idx = 0
|
idx = 0
|
||||||
@@ -403,14 +404,14 @@ if __name__=='__main__':
|
|||||||
bn = secd['bookname']
|
bn = secd['bookname']
|
||||||
tpy = secd[bn][str(sidx)]['type']
|
tpy = secd[bn][str(sidx)]['type']
|
||||||
|
|
||||||
books[bn]['author'] = secd[bn]['author']
|
bks[bn]['author'] = secd[bn]['author']
|
||||||
books[bn][str(sidx)] = secd[bn][str(sidx)]
|
bks[bn][str(sidx)] = secd[bn][str(sidx)]
|
||||||
|
|
||||||
# not add note to highlight content here,
|
# not add note to highlight content here,
|
||||||
# because NT maybe duplicated, we need remove duplication record before
|
# because NT maybe duplicated, we need remove duplication record before
|
||||||
"""
|
"""
|
||||||
if tpy=='NT' and books[bn][str(sidx-1)]['type']=='HL':
|
if tpy=='NT' and bks[bn][str(sidx-1)]['type']=='HL':
|
||||||
books[bn][str(sidx-1)]['content'] += str(NTPREF+sec[2])
|
bks[bn][str(sidx-1)]['content'] += str(NTPREF+sec[2])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
else: # BM or not correct format section
|
else: # BM or not correct format section
|
||||||
@@ -418,6 +419,12 @@ if __name__=='__main__':
|
|||||||
|
|
||||||
# initial section for next section loop
|
# initial section for next section loop
|
||||||
sec = []
|
sec = []
|
||||||
|
return bks
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
#books = defaultdict(dict)
|
||||||
|
books = import_clips()
|
||||||
|
|
||||||
# remove duplication
|
# remove duplication
|
||||||
drop_duplicate(books)
|
drop_duplicate(books)
|
||||||
@@ -443,5 +450,3 @@ if __name__=='__main__':
|
|||||||
# print data with json format
|
# print data with json format
|
||||||
logger.debug(json.dumps(books, indent=4, sort_keys=True, ensure_ascii=False))
|
logger.debug(json.dumps(books, indent=4, sort_keys=True, ensure_ascii=False))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import sys
|
|||||||
from PySide2.QtWidgets import QApplication
|
from PySide2.QtWidgets import QApplication
|
||||||
from PySide2.QtWidgets import QMainWindow
|
from PySide2.QtWidgets import QMainWindow
|
||||||
from mainwindow import Ui_MainWindow
|
from mainwindow import Ui_MainWindow
|
||||||
|
from kman import *
|
||||||
|
|
||||||
class kmanWindow(QMainWindow):
|
class kmanWindow(QMainWindow):
|
||||||
"""
|
"""
|
||||||
@@ -18,8 +19,10 @@ class kmanWindow(QMainWindow):
|
|||||||
ui.setupUi(self)
|
ui.setupUi(self)
|
||||||
self.ui = ui
|
self.ui = ui
|
||||||
|
|
||||||
|
books = import_clips()
|
||||||
|
|
||||||
# connect action to slot functions
|
# connect action to slot functions
|
||||||
ui.actionimportkindle.triggered.connect(lambda: self.importkindle())
|
ui.actionimportkindle.triggered.connect(lambda: self.importkindle(books))
|
||||||
ui.actionimportlocal.triggered.connect(lambda: self.importlocal())
|
ui.actionimportlocal.triggered.connect(lambda: self.importlocal())
|
||||||
ui.actionconfig.triggered.connect(lambda: self.config())
|
ui.actionconfig.triggered.connect(lambda: self.config())
|
||||||
ui.actionwords.triggered.connect(lambda: self.words())
|
ui.actionwords.triggered.connect(lambda: self.words())
|
||||||
@@ -29,8 +32,9 @@ class kmanWindow(QMainWindow):
|
|||||||
ui.actionflush.triggered.connect(lambda: self.flush())
|
ui.actionflush.triggered.connect(lambda: self.flush())
|
||||||
|
|
||||||
# define slot functions
|
# define slot functions
|
||||||
def importkindle(self):
|
def importkindle(self,bks):
|
||||||
print("call slot importkindle()")
|
print("call slot importkindle()")
|
||||||
|
print(bks)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def importlocal(self):
|
def importlocal(self):
|
||||||
|
|||||||
@@ -168,10 +168,10 @@
|
|||||||
<normaloff>icons/refresh.png</normaloff>icons/refresh.png</iconset>
|
<normaloff>icons/refresh.png</normaloff>icons/refresh.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>flush</string>
|
<string>refresh</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>flush import file</string>
|
<string>refresh import file/quick import from kindle</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionwords">
|
<action name="actionwords">
|
||||||
|
|||||||
3
searchtitle.md
Normal file
3
searchtitle.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
TYPE|BOOKNAME|AUTHOR|MARKTIME|CONTENT
|
||||||
|
--|--|--|--|--
|
||||||
|
HL|薛兆丰经济学讲义 |薛兆丰|2020/1/13 8:11:05|么到底什么叫边际?边际就是“新增”带来的“新增”。 例如,边际成本就是每新增一个单位产品所需要付出的新增成本;边际收入是每多卖一个产品能够带来的新增收入;边际产量是每新增一份投入所带来的新增产量;边际效用是每消耗一个单位的商品所能带来的新增享受。
|
||||||
1
xx
Normal file
1
xx
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"\u859b\u5146\u4e30\u7ecf\u6d4e\u5b66\u8bb2\u4e49 ": {"author": "\u859b\u5146\u4e30", "1": {"type": "HL", "position": "1408-1410", "day": "2020\u5e741\u670813\u65e5", "week": "\u661f\u671f\u4e00", "meridiem": "\u4e0a\u5348", "time": "8:11:05", "content": "\u4e48\u5230\u5e95\u4ec0\u4e48\u53eb\u8fb9\u9645\uff1f\u8fb9\u9645\u5c31\u662f\u201c\u65b0\u589e\u201d\u5e26\u6765\u7684\u201c\u65b0\u589e\u201d\u3002 \u4f8b\u5982\uff0c\u8fb9\u9645\u6210\u672c\u5c31\u662f\u6bcf\u65b0\u589e\u4e00\u4e2a\u5355\u4f4d\u4ea7\u54c1\u6240\u9700\u8981\u4ed8\u51fa\u7684\u65b0\u589e\u6210\u672c\uff1b\u8fb9\u9645\u6536\u5165\u662f\u6bcf\u591a\u5356\u4e00\u4e2a\u4ea7\u54c1\u80fd\u591f\u5e26\u6765\u7684\u65b0\u589e\u6536\u5165\uff1b\u8fb9\u9645\u4ea7\u91cf\u662f\u6bcf\u65b0\u589e\u4e00\u4efd\u6295\u5165\u6240\u5e26\u6765\u7684\u65b0\u589e\u4ea7\u91cf\uff1b\u8fb9\u9645\u6548\u7528\u662f\u6bcf\u6d88\u8017\u4e00\u4e2a\u5355\u4f4d\u7684\u5546\u54c1\u6240\u80fd\u5e26\u6765\u7684\u65b0\u589e\u4eab\u53d7\u3002"}, "lines": 1}}
|
||||||
Reference in New Issue
Block a user