Compare commits

..

No commits in common. "f1fc5a24c1a891029f042005678bde72e9c87879" and "bc452a9f64ef6ae17c5e2bcdab754cf040b8e968" have entirely different histories.

1 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,6 @@ import os
username = ""
password = ""
imapserver = ""
N = 500
if not os.path.isdir('notes'):
os.mkdir('notes')
@ -15,10 +14,13 @@ if not os.path.isdir('notes'):
def clean(text):
return "".join(c if c.isalnum() else "_" for c in text)
# number of top emails to fetch
N = 200
imap = imaplib.IMAP4_SSL(imapserver)
imap.login(username, password)
status, messages = imap.select("Notes", True)
status, messages = imap.select("Notes")
messages = int(messages[0])
@ -56,12 +58,13 @@ for i in range(messages, messages-N, -1):
content_type = msg.get_content_type()
body = msg.get_payload(decode=True).decode()
if content_type == "text/plain":
open(filepath, "wb").write(body.encode('utf8'))
open(filepath, "w").write(body)
if content_type == "text/html":
md = markdownify(body)
if md[:4] == 'html':
md = md[4:]
open(filepath, "wb").write(md.encode('utf8'))
imap.close()