Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Reads in the export file from FBReader and imports your notes / bookmarkes / quotes to evernote.
- It's done by sending a mail to your evernote-mail which then creates a note in your default notebook.
- It creates one evernote note per quote. Each titled with the book title.
- Additionally, it creates an optional summary note, which contains all quotes from the given book.
- To use, fill out the settings variables below.
- """
- import os
- import smtplib
- import click
- from tqdm import tqdm
- EVERNOTE_MAIL = 'xxx@m.evernote.com'
- FROM_MAIL = 'xxx@gmail.com'
- SMTP_HOST = 'smtp.gmail.com'
- SMTP_PORT = 587
- SMTP_USER = 'xxx@gmail.com'
- SMTP_PASSWORD = '' # Create an app password in case of using gmail
- @click.command()
- @click.argument('textfile')
- @click.argument('book_title')
- def create_notes(textfile, book_title):
- if not os.path.isfile(textfile):
- raise click.UsageError('The specified textfile does not exist')
- with open(textfile, 'r') as f:
- notes = f.read().split('\n\n')
- click.echo(f'{len(notes)} notes found.')
- click.confirm('Do you want to continue?', abort=True)
- server = smtplib.SMTP(SMTP_HOST, SMTP_PORT)
- server.starttls()
- server.login(SMTP_USER, SMTP_PASSWORD)
- progress_bar = tqdm(total=len(notes))
- for note in notes:
- note_title = book_title
- note_content = note.strip()
- message = 'Subject: {}\n\n{}'.format(note_title, note_content)
- server.sendmail(FROM_MAIL, EVERNOTE_MAIL, message)
- progress_bar.update(1)
- if click.confirm('Do you want to create one additional note which contains all quotes?'):
- note_title = f'{book_title} - All Quotes / Summary'
- note_content = f'In total you made {len(notes)} notes in {book_title}\n\n'
- note_content += '\n\n'.join(notes)
- message = 'Subject: {}\n\n{}'.format(note_title, note_content)
- server.sendmail(FROM_MAIL, EVERNOTE_MAIL, message)
- progress_bar.close()
- server.quit()
- if __name__ == '__main__':
- create_notes()
Add Comment
Please, Sign In to add comment