aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 46870121f0094153ca68f6f26c4df092aad8db36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# arxiv2remarkable.py

This script takes an URL to an arXiv paper, and:

1. Downloads it
2. Removes the arXiv timestamp
3. Crops the pdf to remove unnecessary borders
4. Shrinks the pdf to reduce filesize
5. Generates a nice filename based on author/title/year of the paper
6. Uploads it to the reMarkable

Optionally, you can download a paper but not have it uploaded to the 
reMarkable (using the ``-n`` switch), or provide an existing pdf file (to use 
only steps 2 - 6).

Here's the full help of the script:

```bash
[arxiv2remarkable] $ python arxiv2remarkable.py -h
usage: arxiv2remarkable.py [-h] [-v] [-n] [-d] [--rmapi RMAPI]
                           [--pdfcrop PDFCROP] [--pdftk PDFTK] [--gs GS]
                           input

positional arguments:
  input              url to an arxiv paper or existing pdf file

optional arguments:
  -h, --help         show this help message and exit
  -v, --verbose      be verbose (default: False)
  -n, --no-upload    don't upload to the reMarkable, save the output in
                     current working dir (default: False)
  -d, --debug        debug mode, doesn't upload to reMarkable (default: False)
  --rmapi RMAPI      path to rmapi executable (default: rmapi)
  --pdfcrop PDFCROP  path to pdfcrop executable (default: pdfcrop)
  --pdftk PDFTK      path to pdftk executable (default: pdftk)
  --gs GS            path to gs executable (default: gs)
```

And here's an example with verbose mode enabled that shows everything the 
script does:
```bash
$ python arxiv2remarkable.py -v https://arxiv.org/abs/1811.11242
2019-02-03 18:11:41.816 | INFO     | __main__:download_url:106 - Downloading file at url: https://arxiv.org/pdf/1811.11242v1.pdf
2019-02-03 18:11:46.833 | INFO     | __main__:get_page_with_retry:92 - Downloading url: https://arxiv.org/pdf/1811.11242v1.pdf
2019-02-03 18:11:46.835 | INFO     | __main__:get_paper_info:194 - Getting paper info from arXiv
2019-02-03 18:11:47.496 | INFO     | __main__:get_page_with_retry:92 - Downloading url: https://arxiv.org/abs/1811.11242v1
2019-02-03 18:11:47.508 | INFO     | __main__:generate_filename:206 - Generating output filename
2019-02-03 18:11:47.508 | INFO     | __main__:dearxiv:114 - Removing arXiv timestamp
2019-02-03 18:11:49.221 | INFO     | __main__:crop_pdf:154 - Cropping pdf file
2019-02-03 18:11:53.247 | INFO     | __main__:shrink_pdf:172 - Shrinking pdf file
2019-02-03 18:11:54.802 | INFO     | __main__:upload_to_rm:218 - Starting upload to reMarkable
2019-02-03 18:11:57.767 | INFO     | __main__:upload_to_rm:223 - Upload successful.
```

## Dependencies

The script requires the following external programs to be available:

- [pdftk](https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)
- [pdfcrop](https://ctan.org/pkg/pdfcrop?lang=en): usually included with a 
  LaTeX installation.
- [GhostScript](https://www.ghostscript.com/)
- [rMAPI](https://github.com/juruen/rmapi)

If these scripts are not available on the PATH variable, you can supply them 
with the relevant options to the script.

The script also needs the following Python packages:

- [BeautifulSoup4](https://pypi.org/project/beautifulsoup4/)
- [requests](https://pypi.org/project/requests/)
- [loguru](https://pypi.org/project/loguru/)


# Notes

License: MIT

Author: G.J.J. van den Burg