diff --git a/README.md b/README.md index 30b3f16..2ce9065 100644 --- a/README.md +++ b/README.md @@ -3,33 +3,32 @@ This is a quick-and-dirty python script to log into an IMAP server, monitor incoming messages for the ones that contain the links to the PDFs that you sent from the Kindle scribe. Once such an email is found -the pdf linked therein is downloaded to a local directory and the -email is deleted. The latest downloaded file is also copied to a -preset filename to make it easier to find it. I'm always running -`zathura ~/kindle_dump/latest.pdf` to have the latest kindle pdf -visible. +the PDF linked therein is downloaded to a local directory +`OUTDIR/[name].pdf` (see below) and the email is deleted. The latest +downloaded file is also copied to a preset filename to make it easier +to find it. I'm always running `zathura OUTDIR/.latest.pdf` to +have the latest kindle PDF visible. ## Installation / Usage Either clone this repo and use `poerty install` and the like or run the nix flake with `nix run github:vale981/kindle_fetch -- [args]`. ``` -usage: kindle_fetch [-h] [--outdir OUTDIR] [--current_file CURRENT_FILE] [--imap_folder IMAP_FOLDER] - server user pass_command +usage: kindle_fetch [-h] [--outdir OUTDIR] [--current_file CURRENT_FILE] [--imap_folder IMAP_FOLDER] [--loglevel LOGLEVEL] server user pass_command -Monitors you Email and automatically downloads the notes sent to it. +Monitors you email and automatically downloads the kindle PDF notes sent to it. positional arguments: server the IMAP server to connect to user the IMAP username - pass_command a shell command that returns the password to the server + pass_command A shell command that returns the password to the server. options: -h, --help show this help message and exit - --outdir OUTDIR the directory to dump the note PDFs in + --outdir OUTDIR The kindle note PDFs will be saved into `OUTDIR/[name].pdf`. (default: ~/kindle_dump) --current_file CURRENT_FILE - the path to the file that will contain the the most currently downloaded pdf relative to - `outdir` + The latest downloaded file will be copied to `OUTDIR/[current_file] (default: .latest.pdf) --imap_folder IMAP_FOLDER - the folder to monitor for new messages + The IMAP folder to monitor for new messages. (default: INBOX) + --loglevel LOGLEVEL The python logging level to use. (default: info) ``` diff --git a/flake.lock b/flake.lock index 04337bc..25adc4e 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -44,11 +44,11 @@ ] }, "locked": { - "lastModified": 1703863825, - "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "lastModified": 1729742964, + "narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=", "owner": "nix-community", "repo": "nix-github-actions", - "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "rev": "e04df33f62cdcf93d73e9a04142464753a16db67", "type": "github" }, "original": { @@ -59,11 +59,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717839683, - "narHash": "sha256-kC0eyEsfpXbtQ2Ee5kgjmLFSVsLgnqpj10LjEi+fK+g=", + "lastModified": 1730945957, + "narHash": "sha256-fhkxOv9RGEoPZNyl7VOpHf0Xoqc+bu0J/uW3BSg7tOs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3f3a01219b4a1b6ee63039a3aa63948fbf37c0dd", + "rev": "0093b93ec307d42f51ced7ce90dda6c37516e98a", "type": "github" }, "original": { @@ -84,11 +84,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1717774136, - "narHash": "sha256-comOhXDFUrbVba47gPenVBKy2foM3m3qOqpcP8umWDA=", + "lastModified": 1730961552, + "narHash": "sha256-TjfCllZmU8U2Bs/ENsrii7GCHBDkorPsmZ0d97DcaAQ=", "owner": "nix-community", "repo": "poetry2nix", - "rev": "370da3b6fefc6c11367463b68d010f9950aaa80c", + "rev": "a1925e0848c62ab542b0b93b1b22875ee6efcb3d", "type": "github" }, "original": { @@ -156,11 +156,11 @@ ] }, "locked": { - "lastModified": 1717278143, - "narHash": "sha256-u10aDdYrpiGOLoxzY/mJ9llST9yO8Q7K/UlROoNxzDw=", + "lastModified": 1730120726, + "narHash": "sha256-LqHYIxMrl/1p3/kvm2ir925tZ8DkI0KA10djk8wecSk=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "3eb96ca1ae9edf792a8e0963cc92fddfa5a87706", + "rev": "9ef337e492a5555d8e17a51c911ff1f02635be15", "type": "github" }, "original": { diff --git a/kindle_fetch/kindle_fetch.py b/kindle_fetch/kindle_fetch.py index cd17597..bcf2573 100644 --- a/kindle_fetch/kindle_fetch.py +++ b/kindle_fetch/kindle_fetch.py @@ -219,7 +219,8 @@ async def make_client(host, user, password, folder): def parse_args_and_configure_logging(): parser = argparse.ArgumentParser( prog="kindle_fetch", - description="Monitors you Email and automatically downloads the notes sent to it.", + description="Monitors you email and automatically downloads the kindle PDF notes sent to it.", + formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument("server", type=str, help="the IMAP server to connect to") @@ -227,30 +228,30 @@ def parse_args_and_configure_logging(): parser.add_argument( "pass_command", type=str, - help="a shell command that returns the password to the server", + help="A shell command that returns the password to the server.", ) parser.add_argument( "--outdir", type=str, - help="the directory to dump the note PDFs in", + help="The kindle note PDFs will be saved into `OUTDIR/[name].pdf`.", default="~/kindle_dump", ) parser.add_argument( "--current_file", type=str, - help="the path to the file that will contain the the most currently downloaded pdf relative to `outdir`", - default="latest.pdf", + help="The latest downloaded file will be copied to `OUTDIR/[current_file]", + default=".latest.pdf", ) parser.add_argument( "--imap_folder", type=str, - help="the folder to monitor for new messages", + help="The IMAP folder to monitor for new messages.", default="INBOX", ) parser.add_argument( "--loglevel", default="info", - help="logging level; example --loglevel debug, default=warning", + help="The python logging level to use.", ) args = parser.parse_args() diff --git a/poetry.lock b/poetry.lock index 4718dd2..2fb6abf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,14 +1,13 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "aioimaplib" -version = "1.0.1" +version = "1.1.0" description = "Python asyncio IMAP4rev1 client library" optional = false python-versions = "*" files = [ - {file = "aioimaplib-1.0.1-py3-none-any.whl", hash = "sha256:ebf8387a8febf4d4ae21b35a54cc7c9f4b77c3a7132e3e50c7d6a14993b07bf3"}, - {file = "aioimaplib-1.0.1.tar.gz", hash = "sha256:287fd8a2386f2ff301ac4f8479633292dae80e223e8e40ce2f38038784822afa"}, + {file = "aioimaplib-1.1.0-py3-none-any.whl", hash = "sha256:927b1d24b58e2fd918037bcb4b8dd7f6d42a111ee409969a7c472ed66c5b670f"}, ] [metadata]