kindle manager
This commit is contained in:
13
kman.py
13
kman.py
@@ -63,7 +63,8 @@ SYS = 'WIN' if platform.system()=='Windows' else \
|
||||
# some constants
|
||||
LASTLINE = '=========='
|
||||
NTPREF = '--CG注:'
|
||||
CLIPPATH = './My Clippings.txt' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
CLIPFN = 'My Clippings.txt'
|
||||
CLIPPATH = './' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
#CLIPPATH = './tclip.txt'
|
||||
OUTPREF = './clip'
|
||||
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
||||
@@ -126,7 +127,7 @@ class kMan:
|
||||
kp = self.get_kindle_path()
|
||||
|
||||
if not kp:
|
||||
s2 = u'Disconnected ({})'.format(CLIPPATH)
|
||||
s2 = u'Disconnected ({})'.format(CLIPPATH+CLIPFN)
|
||||
else:
|
||||
with open(kp+'/system/version.txt' , 'r', encoding='utf8', errors='ignore') as f:
|
||||
s2 = u'Connected ({}) version {}'.format(kp,f.read().strip())
|
||||
@@ -192,8 +193,8 @@ class kMan:
|
||||
|
||||
# parse #1 line
|
||||
aus = au.search(authinfo)
|
||||
bookname = aus.group(1).strip()
|
||||
author = aus.group(2).strip()
|
||||
bookname = aus.group(1).strip().replace(' ','')
|
||||
author = aus.group(2).strip().replace(' ','')
|
||||
section[bookname]['author'] = author
|
||||
|
||||
section['bookname'] = bookname
|
||||
@@ -493,7 +494,7 @@ class kMan:
|
||||
for d in sout.split('\n'):
|
||||
if 'Kindle' in d: return d.split('\s+')[0]
|
||||
elif os.name == 'posix': # mac os
|
||||
if sout: return('/Volumes/Kindle')
|
||||
if sout: return('/Volumes/Kindle/')
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -512,7 +513,7 @@ class kMan:
|
||||
|
||||
return False
|
||||
|
||||
def import_clips(self, fp=CLIPPATH):
|
||||
def import_clips(self, fp=(CLIPPATH+CLIPFN)):
|
||||
"""import clips from local file or kindle
|
||||
4 lines for each section seperated with '======='
|
||||
so read 4 lines before '======='
|
||||
|
||||
Reference in New Issue
Block a user