z
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Michael Grote 2024-05-07 01:43:07 +02:00
parent 468e2c9092
commit 053891690e
2 changed files with 7 additions and 17 deletions

View file

@ -77,10 +77,9 @@ If `MF_DEBUG` is set to `1`, `miniflux-filter` will print extra output to stdou
| RC | Description |
| --- | ------------------------------- |
| 1 | `$MF_FILTERLIST_FILE` not found |
| 1 | `$MF_FILTERLIST` not set |
| 2 | `$MF_AUTH_TOKEN` not set |
| 3 | `$MF_API_URL` not set |
| 4 | `$MF_FILTERLIST_FILE` is a dir |
| 5 | `jq` is not installed |
| 6 | `curl` is not installed |
| 7 | could not connect to `miniflux` |

View file

@ -5,8 +5,6 @@ if [[ $MF_DEBUG -eq 1 ]]; then
printf "miniflux-filter - git.mgrote.net/mg/miniflux-filter\n"
fi
### datei mit filter ausdruecken
MF_FILTERLIST_FILE="${MF_FILTERLIST_FILE:=/data/filter.txt}"
### wartezeit zwischen durchlaeufen
MF_SLEEP="${MF_SLEEP:=30}"
### MF_DEBUG output
@ -84,17 +82,11 @@ function check_vars {
echo [ERROR] '"$MF_API_URL"' not set.
exit 3
fi
# prüfe ob filter-datei ein ordner ist
# kann bei einem falschen bind-mount passieren
if [[ -d "$MF_FILTERLIST_FILE" ]]; then
# shellcheck disable=SC2102
echo [ERROR] "$MF_FILTERLIST_FILE" is a directory!
exit 4
fi
# pruefe ob filter-datei NICHT existiert
if [[ ! -e "$MF_FILTERLIST_FILE" ]]; then
if [[ -z "${MF_FILTERLIST}" ]]; then
# shellcheck disable=SC2016
# shellcheck disable=SC2102
echo [ERROR] "$MF_FILTERLIST_FILE" not readable!
echo [ERROR] '"$MF_FILTERLIST"' not set.
exit 1
fi
}
@ -142,11 +134,10 @@ function check_api_connectivity {
function debug_output {
if [[ $MF_DEBUG -eq 1 ]]; then
echo -----------------------------------------------------
echo [DEBUG] Filterlist-File: "$MF_FILTERLIST_FILE"
echo [DEBUG] Sleep-Intervall: "$MF_SLEEP"
echo [DEBUG] Auth-Token: "$MF_AUTH_TOKEN"
echo [DEBUG] MF-Url: "$MF_API_URL"
echo [DEBUG] Anzahl Filter: "$(wc -l < "$MF_FILTERLIST_FILE")"
echo [DEBUG] Anzahl Filter: "$(wc -l < "$MF_FILTERLIST")"
echo -----------------------------------------------------
fi
}
@ -165,7 +156,7 @@ function get_unread_entries {
}
function filter_entries {
echo "[INFO] Filtering entries..."
# fuer jede Zeile in $MF_FILTERLIST_FILE
# fuer jede Zeile in $MF_FILTERLIST
while read -r line; do
if [[ $MF_DEBUG -eq 1 ]]; then
echo "[DEBUG] set search values"
@ -194,7 +185,7 @@ function filter_entries {
marked_entries+=" $(echo "$unread_entries" | jq --arg url "$url" --arg suchbegriff "$suchbegriff" '.entries[] | select(.feed.site_url | ascii_downcase | contains($url)) | select(.content | ascii_downcase | contains($suchbegriff)) | .id' )"
fi
fi
done < "$MF_FILTERLIST_FILE"
done < "$MF_FILTERLIST"
}
function mark_as_read {
# https://stackoverflow.com/questions/3869072/test-for-non-zero-length-string-in-bash-n-var-or-var