README written – option for all titles in the script
This commit is contained in:
parent
2b5ef5d855
commit
362e10b1fe
11
README.md
11
README.md
@ -10,6 +10,15 @@ exported with the marked text in that plain text file.
|
|||||||
send the pdf via email to your kindle. I really don't know why or how you can do it without amazon.
|
send the pdf via email to your kindle. I really don't know why or how you can do it without amazon.
|
||||||
If someone knows how to do that, please tell me.
|
If someone knows how to do that, please tell me.
|
||||||
|
|
||||||
python readClip -b Booktitle [-i path/to/Clippings.txt]
|
python readClip [-b Booktitle] [-i path/to/Clippings.txt]
|
||||||
|
|
||||||
|
You can use the bash to save the output to a file: python readClip > output.md
|
||||||
|
|
||||||
|
### Booktitle
|
||||||
|
You can search for one booktitle with -b or just print all books. It is not neccessary to include
|
||||||
|
the whole title, it is enough to find a matching with the title. If you have a lot of similar
|
||||||
|
titles, you may want to specify the search. Otherwise just the first finding will get printed.
|
||||||
|
|
||||||
|
### Clippings
|
||||||
|
Per default the script searches for `My\ Clippings.txt` in the working directory.
|
||||||
|
|
||||||
|
26
readClip.py
26
readClip.py
@ -9,7 +9,7 @@ parser.add_argument('-i', type=argparse.FileType("r"),\
|
|||||||
help='Input Clippings')
|
help='Input Clippings')
|
||||||
parser.add_argument('-b', type=str,\
|
parser.add_argument('-b', type=str,\
|
||||||
dest='book', \
|
dest='book', \
|
||||||
help='Book to search for')
|
help='Booktitle to search for')
|
||||||
|
|
||||||
args=parser.parse_args()
|
args=parser.parse_args()
|
||||||
|
|
||||||
@ -39,26 +39,38 @@ def printLines(s):
|
|||||||
newEntry = 0
|
newEntry = 0
|
||||||
foundBook = False
|
foundBook = False
|
||||||
foundBookPast = False
|
foundBookPast = False
|
||||||
|
bookOld = ""
|
||||||
for line in iline:
|
for line in iline:
|
||||||
if line.find("==========") == -1:
|
if line.find("==========") == -1:
|
||||||
if newEntry == 1:
|
if newEntry == 1:
|
||||||
foundBook = False
|
foundBook = False
|
||||||
book = line
|
book = line
|
||||||
if book.find(args.book) != -1:
|
if args.book:
|
||||||
foundBook = True
|
if book.find(args.book) != -1:
|
||||||
if not foundBookPast:
|
foundBook = True
|
||||||
|
if not foundBookPast:
|
||||||
|
print("# " + line)
|
||||||
|
print("## Anmerkungen")
|
||||||
|
foundBookPast = True
|
||||||
|
else:
|
||||||
|
if bookOld != line:
|
||||||
|
foundBook = True
|
||||||
print("# " + line)
|
print("# " + line)
|
||||||
print("## Anmerkungen")
|
print("## Anmerkungen")
|
||||||
foundBookPast = True
|
bookOld = line
|
||||||
newEntry = newEntry + 1
|
newEntry = newEntry + 1
|
||||||
elif foundBook:
|
elif foundBook:
|
||||||
if newEntry == 2:
|
if newEntry == 2:
|
||||||
page = line.split('Seite ')[1].split('|', 1)[0].strip()
|
if line.find("Seite") != -1:
|
||||||
|
splt = 'Seite '
|
||||||
|
else:
|
||||||
|
splt = 'Position '
|
||||||
|
page = line.split(splt)[1].split('|', 1)[0].strip()
|
||||||
if page.find('-') != -1:
|
if page.find('-') != -1:
|
||||||
if page.split('-')[0] == page.split('-')[1]:
|
if page.split('-')[0] == page.split('-')[1]:
|
||||||
page = page.split('-')[0]
|
page = page.split('-')[0]
|
||||||
if line.find("Markierung") != -1:
|
if line.find("Markierung") != -1:
|
||||||
print("- Seite " + page + ":")
|
print("- " + splt + page + ":")
|
||||||
if line.find("Notiz") != -1:
|
if line.find("Notiz") != -1:
|
||||||
print("- Seite " + page + " (*Notiz*):")
|
print("- Seite " + page + " (*Notiz*):")
|
||||||
elif newEntry > 2:
|
elif newEntry > 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user