diff options
| author | 2019-10-13 11:11:39 +0530 | |
|---|---|---|
| committer | 2019-10-13 12:06:32 +0530 | |
| commit | 19ea710e083a0e666a6cb8feea0dc0559e0a2416 (patch) | |
| tree | 94891b807b80b98dec3305e19138862f47b35a30 /plugins/gutenread | |
| parent | 6d7c25822a89de1deb0a6326ab37160198b3a703 (diff) | |
| download | nnn-19ea710e083a0e666a6cb8feea0dc0559e0a2416.tar.gz | |
gutenread: support epub
Diffstat (limited to 'plugins/gutenread')
| -rwxr-xr-x | plugins/gutenread | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/gutenread b/plugins/gutenread index 40ef2ac..c1ff6ba 100755 --- a/plugins/gutenread +++ b/plugins/gutenread @@ -6,11 +6,15 @@ # Details: Set the variable EBOOK_ID to download in html format and read in w3m. # Clear EBOOK_ID to browse available ebooks by popularity and set it to # the ID once you find an interesting one. +# To dowload and read in epub format set READER to an epub reader like +# epr: https://github.com/wustho/epr # -# For example: +# More on EBOOK_ID: # Wuthering Heights by Emily Brontë is at https://www.gutenberg.org/ebooks/768 # So EBOOK_ID would be 768 # +# Downloaded ebooks are at ${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/ +# # Shell: POSIX compliant # Author: Arun Prakash Jana @@ -18,17 +22,27 @@ EBOOK_ID= DIR=${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/"$EBOOK_ID" BROWSE_LINK="http://www.gutenberg.org/ebooks/search/?sort_order=downloads" BROWSER=w3m +READER= if [ ! -z "$EBOOK_ID" ]; then if [ ! -e $DIR ]; then mkdir -p $DIR cd $DIR - curl -L -O "https://www.gutenberg.org/files/"$EBOOK_ID"/"$EBOOK_ID"-h.zip" - unzip "$EBOOK_ID"-h.zip + + if [ -z "$READER" ]; then + curl -L -O "https://www.gutenberg.org/files/"$EBOOK_ID"/"$EBOOK_ID"-h.zip" + unzip "$EBOOK_ID"-h.zip + else + curl -L -o "$EBOOK_ID".epub "http://www.gutenberg.org/ebooks/"$EBOOK_ID".epub.noimages" + fi fi if [ -d $DIR ]; then - "$BROWSER" $DIR/"$EBOOK_ID"-h/"$EBOOK_ID"-h.htm + if [ -z "$READER" ]; then + "$BROWSER" $DIR/"$EBOOK_ID"-h/"$EBOOK_ID"-h.htm + else + "$READER" $DIR/"$EBOOK_ID".epub + fi fi else "$BROWSER" $BROWSE_LINK |