added mrss.sh script

This commit is contained in:
dogeystamp 2023-02-08 19:35:00 -05:00
parent 25f01b702a
commit 4d0c47e2c9
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 120 additions and 4 deletions

43
README
View File

@ -50,11 +50,46 @@ in order to successfully run MinRSS.
};
Using MinRSS
Manual usage
------------
Make a directory to store your RSS feeds, then cd into it. Then, enter
the minrss command to download the RSS feeds. Your feeds will be
available as folders in your current working directory.
If you compile with OUTPUT_HTML (as is default), you can read feeds with just
the 'minrss' binary, basic shell utilities and (preferably) a browser of any
kind.
Make a directory to store your RSS feeds, then cd into it. Then, run the minrss
binary to download all articles.
Each configured feed will now appear as a folder, and articles as HTML files
within them. You can open the files in a browser to see the summary text, and
also follow the link to see the full article.
To see which files are new, use 'ls -t' or compile with SUMMARY_FILES.
It is important to note that MinRSS does not download the full text of each
article, but only the summary. If you wish to archive the full text for offline
reading, consider writing a script for it.
Wrapper scripts
---------------
The wrapper script contrib/mrss.sh is provided with MinRSS as an example.
To install it, run the following:
cp contrib/mrss.sh ~/.local/bin/mrss
chmod 755 ~/.local/bin/mrss
The script requires compiling with configuration options OUTPUT_JSON and
SUMMARY_FILES, as well as having jq and xdg-open installed.
By default, mrss sets up a directory at ~/rss/ to store all feeds. To change
this, set MRSS_DIR.
'mrss update' will check feeds for new articles and download them. Symlinks to
new articles are also stored in ~/rss/new/.
'mrss read' can be used on article files to open them in a browser or mpv.
Run 'mrss --help' for further usage help.
Compatibility
-------------

81
contrib/mrss.sh Executable file
View File

@ -0,0 +1,81 @@
#!/bin/sh
set -e
scriptname=$0
subcmd=$1
if [ -z "$MRSS_DIR" ]; then
MRSS_DIR="$HOME/rss"
fi
mkdir -p "$MRSS_DIR"
sub_help() {
echo "usage:"
echo " $scriptname <command> [options]"
echo
echo "commands:"
echo " update updates feeds"
echo " read opens link from an article file in either a browser or mpv"
echo " link print the article link from a .json file"
echo " purge purge new/ directory"
echo
echo "The following is required to use this script:"
echo " - jq"
echo " - minrss compiled with:"
echo " * OUTPUT_JSON"
echo " * SUMMARY_FILES"
}
sub_update() {
cd "$MRSS_DIR"
minrss | {
while read -r ARTICLE; do
DIRNAME="$(dirname "$ARTICLE")"
BASENAME="$(basename "$ARTICLE")"
mkdir -p "$MRSS_DIR"/new/"$DIRNAME"
ln -sr "$MRSS_DIR"/"$ARTICLE" "$MRSS_DIR"/new/"$ARTICLE"
done
}
}
sub_purge() {
cd "$MRSS_DIR"
rm -r "$MRSS_DIR"/new/*
}
sub_link() {
# extract the link from a single article file
cat "$@" | jq -r '.enclosure.link // .link'
}
sub_read() {
VID=""
for art in "$@"; do
LINK="$(sub_link "$art")"
if [ ! -z "$(printf "%s" "$LINK" | grep 'youtube.com\|odycdn\|simplecastaudio\|podcasts\|twitch')" ]; then
VID="$VID$LINK "
else
xdg-open $LINK &
fi
done
if [ -n "$VID" ]; then
mpv $VID
fi
}
case $subcmd in
"" | "--help" | "-h")
sub_help
;;
*)
shift
sub_${subcmd} "$@"
if [ $? = 127 ]; then
echo "error: unknown command '$subcmd'"
exit 1
fi
;;
esac