Compare commits
No commits in common. "dd5666a0067f1292c4a40d7b2ebd35738e3ddbc4" and "59c6f89662e5000420b33a657022ff74708b1aae" have entirely different histories.
dd5666a006
...
59c6f89662
@ -23,17 +23,13 @@ sub_help() {
|
|||||||
echo
|
echo
|
||||||
echo "commands:"
|
echo "commands:"
|
||||||
echo " update updates feeds"
|
echo " update updates feeds"
|
||||||
|
echo " read opens link from an article file in either a browser or mpv"
|
||||||
echo " select show each new article and prompt for an action;"
|
echo " select show each new article and prompt for an action;"
|
||||||
echo " you can run 'select new/feed' for a specific feed"
|
echo " you can run 'select new/feed' for a specific feed"
|
||||||
echo " or 'select watch-later'."
|
echo " or 'select watch-later'."
|
||||||
echo " fzf show articles using fzf"
|
echo " fzf select articles to read using fzf"
|
||||||
echo " same usage as 'select'"
|
echo " link print the article link from a .json file"
|
||||||
echo
|
echo " purge purge new/ directory"
|
||||||
echo "article commands (pass files as arguments):"
|
|
||||||
echo " read opens link from an article file in either a browser or mpv"
|
|
||||||
echo " link print the article link"
|
|
||||||
echo " purge mark an article read, or mark all articles read (if no args passed)"
|
|
||||||
echo " watchlater move articles to a watch-later directory"
|
|
||||||
echo
|
echo
|
||||||
echo "The following is required to use this script:"
|
echo "The following is required to use this script:"
|
||||||
echo " - jq"
|
echo " - jq"
|
||||||
@ -58,32 +54,13 @@ sub_update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_purge() {
|
|
||||||
while read -r ARTICLE; do
|
|
||||||
if [ -h "$ARTICLE" ]; then
|
|
||||||
rm "$ARTICLE"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_purge() {
|
sub_purge() {
|
||||||
if [ -z "$@" ]; then
|
|
||||||
cd "$MRSS_DIR"
|
cd "$MRSS_DIR"
|
||||||
rm -r "$MRSS_NEWDIR"/*
|
rm -r "$MRSS_NEWDIR"/*
|
||||||
else
|
|
||||||
for art in "$@"; do
|
|
||||||
printf "%s\n" "$art"
|
|
||||||
done | list_purge
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
list_link() {
|
|
||||||
for art in "$@"; do
|
|
||||||
cat "$art" | jq -r '.enclosure.link // .link'
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_link() {
|
sub_link() {
|
||||||
|
# extract the link from a single article file
|
||||||
cat "$@" | jq -r '.enclosure.link // .link'
|
cat "$@" | jq -r '.enclosure.link // .link'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,13 +79,16 @@ list_read() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
xdg-open $LINK 2> /dev/null &
|
xdg-open $LINK 2> /dev/null &
|
||||||
sub_purge "$art"
|
if [ -h "$art" ]; then
|
||||||
|
# remove symlinks from new/
|
||||||
|
rm "$art"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$VID" ]; then
|
if [ -n "$VID" ]; then
|
||||||
if mpv $VID 2> /dev/null; then
|
if mpv $VID 2> /dev/null; then
|
||||||
printf "%s" "$VIDFILES" | list_purge
|
printf "%s" "$VIDFILES" | xargs -d "\n" rm
|
||||||
else
|
else
|
||||||
printf "\n%s%s%s\n" \
|
printf "\n%s%s%s\n" \
|
||||||
$blue \
|
$blue \
|
||||||
@ -118,23 +98,9 @@ list_read() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
list_watchlater() {
|
|
||||||
while read -r ARTICLE; do
|
|
||||||
REALPATH="$(realpath "$ARTICLE")"
|
|
||||||
sub_purge "$ARTICLE"
|
|
||||||
ln -sr "$REALPATH" "$MRSS_WATCH_LATER"/
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_watchlater() {
|
|
||||||
for art in "$@"; do
|
|
||||||
printf "%s\n" "$art"
|
|
||||||
done | list_watchlater
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_read() {
|
sub_read() {
|
||||||
for art in "$@"; do
|
for art in "$@"; do
|
||||||
printf "%s\n" "$art"
|
echo "$art"
|
||||||
done | list_read
|
done | list_read
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +126,7 @@ sub_select() {
|
|||||||
else
|
else
|
||||||
DIR="$MRSS_DIR/$1"
|
DIR="$MRSS_DIR/$1"
|
||||||
fi
|
fi
|
||||||
NEWARTS="$(find "$DIR" -type l -or -type f)"
|
NEWARTS="$(find "$DIR" -type l)"
|
||||||
TOTAL_COUNT="$(printf "%s" "$NEWARTS" | wc -l)"
|
TOTAL_COUNT="$(printf "%s" "$NEWARTS" | wc -l)"
|
||||||
printf "%s" "$NEWARTS" | (
|
printf "%s" "$NEWARTS" | (
|
||||||
|
|
||||||
@ -176,7 +142,7 @@ sub_select() {
|
|||||||
sub_preview "$ARTICLE"
|
sub_preview "$ARTICLE"
|
||||||
|
|
||||||
printf "\n\n-----------------\n"
|
printf "\n\n-----------------\n"
|
||||||
printf "\nq quit, r read, e queue article, f full summary, d purge (mark read),\n"
|
printf "\nq quit, r read, e queue article, f full summary, d mark read,\n"
|
||||||
printf "s skip, S skip all, w watch later\n"
|
printf "s skip, S skip all, w watch later\n"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
@ -196,11 +162,16 @@ sub_select() {
|
|||||||
cat "$ARTICLE" | jq -r '.description // ""' | w3m -o confirm_qq=false -T text/html
|
cat "$ARTICLE" | jq -r '.description // ""' | w3m -o confirm_qq=false -T text/html
|
||||||
;;
|
;;
|
||||||
d )
|
d )
|
||||||
sub_purge "$ARTICLE"
|
if [ -h "$ARTICLE" ]; then
|
||||||
|
rm "$ARTICLE"
|
||||||
|
fi
|
||||||
break;;
|
break;;
|
||||||
s ) break;;
|
s ) break;;
|
||||||
S ) SKIPALL="y"; break;;
|
S ) SKIPALL="y"; break;;
|
||||||
w ) sub_watchlater "$ARTICLE"
|
w )
|
||||||
|
REALPATH="$(realpath "$ARTICLE")"
|
||||||
|
rm "$ARTICLE"
|
||||||
|
ln -sr "$REALPATH" "$MRSS_WATCH_LATER"/
|
||||||
break;;
|
break;;
|
||||||
* ) break;;
|
* ) break;;
|
||||||
esac
|
esac
|
||||||
@ -219,26 +190,10 @@ sub_fzf() {
|
|||||||
DIR="$MRSS_DIR/$1"
|
DIR="$MRSS_DIR/$1"
|
||||||
fi
|
fi
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
while true; do
|
NEWARTS="$(find . -type l)"
|
||||||
NEWARTS="$(find . -type l -or -type f)"
|
|
||||||
export -f sub_preview
|
export -f sub_preview
|
||||||
SEL="$(printf "%s" "$NEWARTS" | fzf --marker='*' --multi --cycle --preview 'bash -c "sub_preview {}"')"
|
printf "%s" "$NEWARTS" | fzf --disabled --marker='*' --multi --cycle --preview 'bash -c "sub_preview {}"' | \
|
||||||
if [ -z "$SEL" ]; then
|
list_read
|
||||||
break
|
|
||||||
fi
|
|
||||||
clear
|
|
||||||
printf "\nselected %s article(s)\n" "$(printf "%s\n" "$SEL" | wc -l)"
|
|
||||||
printf "\nq quit, r read, d purge (mark read), D purge all, w watch later\n"
|
|
||||||
printf "\n> "
|
|
||||||
read -n 1 ans </dev/tty
|
|
||||||
case "$ans" in
|
|
||||||
q ) exit;;
|
|
||||||
r ) printf '%s\n' "$SEL" | list_read;;
|
|
||||||
D ) sub_purge; break;;
|
|
||||||
d ) printf '%s\n' "$SEL" | list_purge;;
|
|
||||||
w ) printf '%s\n' "$SEL" | list_watchlater;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case $subcmd in
|
case $subcmd in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user