summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2025-11-05 12:35:30 +0100
committeryctct <yctct@yctct.com>2025-11-05 12:35:30 +0100
commit5c09b3c2adff3434b19e78bb7f2d8af698fde26b (patch)
tree7e94dd0b62dc0a0691ad32aa790bcfb4877f17b6
Add files
-rw-r--r--README.txt28
-rwxr-xr-xsave-article-to-epub.py20
2 files changed, 48 insertions, 0 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..5c94d7f
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,28 @@
+This is a script to save an article from Newsboat RSS reader to an epub file.
+
+Setup
+------
+
+- copy the script into a file in ~/bin
+- make sure that ~/bin is included in $PATH ($ echo $PATH)
+- make the script executable by running
+
+ $ chmod u+x script.sh
+
+- modify the path to the directory where you'd like epub files to be saved -- see comment in script
+- add these two lines to newsboat's config file, probably located at ~/.newsboat/config
+
+ # Save article .epub
+ macro S pipe-to "~/bin/save-article-to-epub.py"
+
+Usage
+------
+
+- in Newsboat, when you want to save an article, press , then shift + S.
+
+License
+-------
+
+GPLv3
+
+Script originally written by Ludivico Gerardi.
diff --git a/save-article-to-epub.py b/save-article-to-epub.py
new file mode 100755
index 0000000..c2c9047
--- /dev/null
+++ b/save-article-to-epub.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import sys
+import subprocess
+
+article = ""
+title = ""
+for line in sys.stdin:
+ article = article + line
+ if not title and line.startswith("Title:"):
+ title = line[7:].strip()
+
+subprocess.run(
+ # uncomment to save in current directory
+ # ["pandoc", "--metadata", f'title="{title}"', "-o", title + ".epub"], input=bytes(article, encoding="utf-8"),
+ # save in designated directory /home/user/epub/
+ ["pandoc", "--metadata", f'title="{title}"', "-o", "/home/user/epub/" + title + ".epub"],
+ input=bytes(article, encoding="utf-8"),
+)
+print(title, "has been saved as an epub file.")