contrib/mrss.sh: article titles now used in fzf
this means no more filename issues like accented characters being filtered out
This commit is contained in:
parent
d8f2ad2361
commit
3d168d4f9e
@ -65,14 +65,19 @@ list_purge() {
|
|||||||
while read -r ARTICLE; do
|
while read -r ARTICLE; do
|
||||||
if [ -h "$ARTICLE" ]; then
|
if [ -h "$ARTICLE" ]; then
|
||||||
rm "$ARTICLE"
|
rm "$ARTICLE"
|
||||||
|
if [ -n "$INDXFILE" ]; then
|
||||||
|
ENTRY="$(grep "^[0-9]*: $ARTICLE" "$INDXFILE")"
|
||||||
|
ID="$(printf "%s" "$ENTRY" | grep -o "^[0-9]*")"
|
||||||
|
sed -i "/^$ID:.*$/d" "$LISTFILE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_purge() {
|
sub_purge() {
|
||||||
if [ -z "$@" ]; then
|
if [ -z "$@" ]; then
|
||||||
cd "$MRSS_DIR"
|
cd "$MRSS_DIR"/new
|
||||||
rm -r "$MRSS_NEWDIR"/*
|
find . -type l -or -type f | list_purge
|
||||||
else
|
else
|
||||||
for art in "$@"; do
|
for art in "$@"; do
|
||||||
printf "%s\n" "$art"
|
printf "%s\n" "$art"
|
||||||
@ -124,7 +129,7 @@ list_read() {
|
|||||||
VIDFILES="$art"
|
VIDFILES="$art"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
xdg-open $LINK 2> /dev/null &
|
xdg-open "$LINK" 2> /dev/null &
|
||||||
sub_purge "$art"
|
sub_purge "$art"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -153,7 +158,11 @@ sub_preview() {
|
|||||||
|
|
||||||
ARTICLE="$1"
|
ARTICLE="$1"
|
||||||
|
|
||||||
DIRNAME="$(basename $(dirname "$ARTICLE"))"
|
DIRNAME="$(cat "$ARTICLE" | jq -r '.feedname // ""')"
|
||||||
|
if [ -z "$DIRNAME" ]; then
|
||||||
|
DIRNAME="$(basename $(dirname "$ARTICLE"))"
|
||||||
|
fi
|
||||||
|
|
||||||
TITLE="$(cat "$ARTICLE" | jq -r '.title')"
|
TITLE="$(cat "$ARTICLE" | jq -r '.title')"
|
||||||
DESC_TRUNC="$(cat "$ARTICLE" | jq -r '.description // ""' | w3m -dump -T text/html | head -n 20)"
|
DESC_TRUNC="$(cat "$ARTICLE" | jq -r '.description // ""' | w3m -dump -T text/html | head -n 20)"
|
||||||
|
|
||||||
@ -235,6 +244,21 @@ sub_select() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_fzf_filename() {
|
||||||
|
# searches entry in index and returns its filename
|
||||||
|
while read -r ENTRY; do
|
||||||
|
ID="$(printf "%s" "$ENTRY" | grep -o "^[0-9]*")"
|
||||||
|
grep "^$ID: " "$INDXFILE" | sed "s/^[0-9]*: //"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
sub_fzf_preview() {
|
||||||
|
# wrapper over sub_preview() that runs fzf_filename
|
||||||
|
INDXFILE="$1"
|
||||||
|
ENTRY="$2"
|
||||||
|
sub_preview "$(echo "$ENTRY" | list_fzf_filename "$INDXFILE")"
|
||||||
|
}
|
||||||
|
|
||||||
sub_fzf() {
|
sub_fzf() {
|
||||||
while getopts ":s" flag; do
|
while getopts ":s" flag; do
|
||||||
case "$flag" in
|
case "$flag" in
|
||||||
@ -250,15 +274,25 @@ sub_fzf() {
|
|||||||
fi
|
fi
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
|
|
||||||
while true; do
|
LISTFILE=`mktemp --suffix=mrss`
|
||||||
NEWARTS="$(find . -type l -or -type f)"
|
INDXFILE=`mktemp --suffix=mrss`
|
||||||
if [ -n "$MRSS_SHUF" ]; then
|
|
||||||
NEWARTS=`printf "%s" "$NEWARTS" | shuf`
|
|
||||||
fi
|
|
||||||
|
|
||||||
OUTPUT="$(printf "%s" "$NEWARTS" |
|
COUNTER="1"
|
||||||
|
find . -type l -or -type f \
|
||||||
|
| ([ -n "$MRSS_SHUF" ] && shuf || cat) \
|
||||||
|
| nl -ba -d'' -n'rz' -s': ' -w1 \
|
||||||
|
> "$INDXFILE"
|
||||||
|
|
||||||
|
cat "$INDXFILE" | sed "s/^[0-9]*: //" \
|
||||||
|
| xargs -rd "\n" cat \
|
||||||
|
| jq -r '[.feedname?, .title] | map(select(. != null)) | join(" - ")' \
|
||||||
|
| nl -ba -d'' -n'rz' -s': ' -w1 \
|
||||||
|
> "$LISTFILE"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
OUTPUT="$(cat "$LISTFILE" |
|
||||||
fzf --marker='*' --multi --print-query \
|
fzf --marker='*' --multi --print-query \
|
||||||
--preview "cd $DIR; mrss preview {}" \
|
--preview "cd $DIR; mrss fzf_preview '$INDXFILE' {}" \
|
||||||
--bind "ctrl-d:change-query(/purge)+accept" \
|
--bind "ctrl-d:change-query(/purge)+accept" \
|
||||||
--bind "ctrl-alt-d:change-query(/purge-all)+accept" \
|
--bind "ctrl-alt-d:change-query(/purge-all)+accept" \
|
||||||
--bind "enter:change-query(/read)+accept" \
|
--bind "enter:change-query(/read)+accept" \
|
||||||
@ -272,7 +306,7 @@ sub_fzf() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SEL="$(printf "%s" "$OUTPUT" | tail -n+2)"
|
SEL="$(printf "$OUTPUT\n" | tail -n+2 | list_fzf_filename)"
|
||||||
ACTION="$(printf "%s" "$OUTPUT" | head -n 1 | tail -c+2)"
|
ACTION="$(printf "%s" "$OUTPUT" | head -n 1 | tail -c+2)"
|
||||||
|
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
@ -303,6 +337,9 @@ sub_fzf() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm "$LISTFILE"
|
||||||
|
rm "$INDXFILE"
|
||||||
|
|
||||||
if [ -n "$QUEUE" ]; then
|
if [ -n "$QUEUE" ]; then
|
||||||
printf "%s\n" "$QUEUE" | list_read
|
printf "%s\n" "$QUEUE" | list_read
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user