aboutsummaryrefslogtreecommitdiff
path: root/arxiv2remarkable.py
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-02-12 12:08:47 +0000
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-02-12 12:08:47 +0000
commit9ce1b9090dc151f31fbb3e9d1b62e1e4f6b75efc (patch)
treecc7f593a057ac70b7f69aba2d03e8ceaf090e96b /arxiv2remarkable.py
parentAlso update dearxiv function for older papers (diff)
downloadpaper2remarkable-9ce1b9090dc151f31fbb3e9d1b62e1e4f6b75efc.tar.gz
paper2remarkable-9ce1b9090dc151f31fbb3e9d1b62e1e4f6b75efc.zip
Add CLI flag to specify the destination directory on rM
Diffstat (limited to 'arxiv2remarkable.py')
-rwxr-xr-xarxiv2remarkable.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/arxiv2remarkable.py b/arxiv2remarkable.py
index 6bb88fc..b09bace 100755
--- a/arxiv2remarkable.py
+++ b/arxiv2remarkable.py
@@ -215,12 +215,18 @@ def generate_filename(info):
def upload_to_rm(filepath, remarkable_dir="/", rmapi_path="rmapi"):
logger.info("Starting upload to reMarkable")
+ if not remarkable_dir == "/":
+ status = subprocess.call([rmapi_path, "mkdir", remarkable_dir])
+ if not status == 0:
+ exception(
+ "Creating directory %s on reMarkable failed" % remarkable_dir
+ )
status = subprocess.call(
[rmapi_path, "put", filepath, remarkable_dir],
stdout=subprocess.DEVNULL,
)
if not status == 0:
- exception("Uploading file %s to remarkable failed" % filepath)
+ exception("Uploading file %s to reMarkable failed" % filepath)
logger.info("Upload successful.")
@@ -244,6 +250,13 @@ def parse_args():
action="store_true",
)
parser.add_argument(
+ "-p",
+ "--remarkable-path",
+ help="directory on reMarkable to put the file (created if missing)",
+ dest="remarkable_dir",
+ default="/",
+ )
+ parser.add_argument(
"--rmapi", help="path to rmapi executable", default="rmapi"
)
parser.add_argument(
@@ -302,7 +315,11 @@ def main():
else:
shutil.move(clean_filename, start_wd)
else:
- upload_to_rm(clean_filename, rmapi_path=args.rmapi)
+ upload_to_rm(
+ clean_filename,
+ remarkable_dir=args.remarkable_dir,
+ rmapi_path=args.rmapi,
+ )
if __name__ == "__main__":