Compare commits

...

25 commits
master ... var

Author SHA1 Message Date
426253b09c ddd
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/build unknown status
2024-05-08 15:00:52 +02:00
920ec231c3 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 03:02:09 +02:00
62b046e08b ffgg
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 03:00:24 +02:00
9ce0ef483c dfgf
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:59:37 +02:00
9ba9b9cc8c sdfg
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:58:42 +02:00
c2f8e8e028 gg
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:57:18 +02:00
70b7e79e6a ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:56:51 +02:00
4ea18d12cc ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:54:31 +02:00
f115b2ac50 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:53:07 +02:00
ba6f13bf02 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:29:08 +02:00
862e5898ad d
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:22:09 +02:00
e2be96f26d ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:16:24 +02:00
07c2468f3b ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:09:13 +02:00
b8e899e3d9 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:08:35 +02:00
f2c47e46f7 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:07:34 +02:00
6fc67f285a dfd
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:06:57 +02:00
1ee00554e4 df
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:06:15 +02:00
a258a857cb ffdff 2024-05-07 02:06:12 +02:00
c163dbf9c7 p
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 02:04:46 +02:00
5ecd464fbe gg
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:55:15 +02:00
a8517d5733 t
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:51:24 +02:00
f451b07764 ff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:50:56 +02:00
6535237f6d d
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:48:20 +02:00
812f1bfe51 f
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:45:56 +02:00
053891690e z
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2024-05-07 01:43:07 +02:00
2 changed files with 131 additions and 36 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` |

164
filter.sh
View file

@ -5,9 +5,7 @@ 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
### wartezeit zwischen laeufen
MF_SLEEP="${MF_SLEEP:=30}"
### MF_DEBUG output
# standardmäßig 0 = aus
@ -25,7 +23,6 @@ Usage:
Options:
-h, --help displays this text
* script gets executed
EOF
}
@ -84,17 +81,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 +133,9 @@ 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] MF-URL: "$MF_API_URL"
echo -----------------------------------------------------
fi
}
@ -165,8 +154,8 @@ function get_unread_entries {
}
function filter_entries {
echo "[INFO] Filtering entries..."
# fuer jede Zeile in $MF_FILTERLIST_FILE
while read -r line; do
# fuer jede Zeile in $MF_FILTERLIST
echo "$MF_FILTERLIST" | while read -r line; do
if [[ $MF_DEBUG -eq 1 ]]; then
echo "[DEBUG] set search values"
fi
@ -189,42 +178,70 @@ function filter_entries {
fi
# das leerzeichen am anfang ist notwendig, trennt die zahlenwerte
# suche in titel
marked_entries+=" $(echo "$unread_entries" | jq --arg url "$url" --arg suchbegriff "$suchbegriff" '.entries[] | select(.feed.site_url | ascii_downcase | contains($url)) | select(.title | ascii_downcase | contains($suchbegriff)) | .id' )"
titles+=" $(echo "$unread_entries" | jq --arg url "$url" --arg suchbegriff "$suchbegriff" '.entries[] | select(.feed.site_url | ascii_downcase | contains($url)) | select(.title | ascii_downcase | contains($suchbegriff)) | .id' )"
# suche in content
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' )"
content+=" $(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"
# sortiere und forme marked_entries um
marked_entries="$title $content"
# https://unix.stackexchange.com/questions/353321/remove-all-duplicate-word-from-string-using-shell-script
# entfernt doppelte eintraege innerhalb einer zeile
marked_entries=$(echo marked_entries | xargs -n1 | sort -u | xargs | sed -r 's/\s/\, /g')
echo "$marked_entries" #d
done
}
function mark_as_read {
# https://stackoverflow.com/questions/3869072/test-for-non-zero-length-string-in-bash-n-var-or-var
# wenn variabler NICHT leer...
# wenn variable NICHT leer...
# sende in put request mit curl
# der wert muss escaped werden, aber NICHT die variable die uebergeben wird
if [[ $MF_DEBUG -eq 1 ]]; then
echo "[DEBUG] mark entries as read"
echo "[DEBUG] marked entry ids:"
# https://unix.stackexchange.com/questions/353321/remove-all-duplicate-word-from-string-using-shell-script
# entfernt doppelte eintraege innerhalb einer zeile
echo "$marked_entries" | xargs -n1 | sort -u | xargs | sed -r 's/\s/\, /g'
echo "$marked_entries"
fi
# wenn NICHT leer
# sed wandelt 123 345 456 in 123, 245, 345 um.
if [[ $(echo "$marked_entries" | xargs -n1 | sort -u | xargs | sed -r 's/\s/\, /g') ]]; then
curl --request PUT --silent --header "X-Auth-Token: $MF_AUTH_TOKEN" --header "Content-Type: application/json" --data "{\"entry_ids\": [$(echo "$marked_entries" | xargs -n1 | sort -u | xargs | sed -r 's/\s/\, /g')], \"status\": \"read\"}" "$MF_API_URL/entries"
# gebe entry-titel aus
for i in $(echo "$marked_entries" | xargs -n1 | sort -u | xargs); do
# gebe aus welcher eintrag gefiltert wurde, cut begrenzt die maximale laenge auf 100 zeichen
# jq "XXX", fügt XXX in ausgabe hinzu
echo [INFO] Filtered entry "$i" - "$(curl --silent --header "X-Auth-Token: $MF_AUTH_TOKEN" "$MF_API_URL"/entries/"$i" | jq --join-output '"url: ",.feed.site_url," - title: ", .title' | cut -c -100)".
done
if [[ -n "$marked_entries" ]]; then
curl --request PUT --silent --header "X-Auth-Token: $MF_AUTH_TOKEN" --header "Content-Type: application/json" --data "{"entry_ids":"$marked_entries"],"status":"read"}" "$MF_API_URL/entries"
# gebe entry-titel aus
for i in "$marked_entries" ; do
# gebe aus welcher eintrag gefiltert wurde, cut begrenzt die maximale laenge auf 100 zeichen
# jq "XXX", fügt XXX in ausgabe hinzu
echo [INFO] Filtered entry "$i" - "$(curl --silent --header "X-Auth-Token: $MF_AUTH_TOKEN" "$MF_API_URL"/entries/"$i" | jq --join-output '"url: ",.feed.site_url," - title: ", .title' | cut -c -100)".
done
fi
# setze variablen auf leer
marked_entries=""
}
# debug
MF_FILTERLIST="
golem.de::Anzeige
golem.de::Aus dem Verlag:
golem.de::Elon Musk
golem.de::Fifa
golem.de::Fussball
golem.de::Fußball
golem.de::(g+)
golem.de::Golem Karrierewelt
golem.de::PODCAST BESSER WISSEN:
golem.de::Sonst noch was?
golem.de::Star Trek:
golem.de::Tech Talks:
golem.de::Twitter
golem.de::Wochenrückblick
heise.de::Dienstag:
heise.de::Die Produktwerker
heise.de::Elon Musk
heise.de::Ferris Talk
heise.de::FIFA
heise.de::Freitag
heise.de::Fußball-WM
heise.de::heise+
"
# Doing
case "$1" in
--help | -h | help)
@ -245,3 +262,82 @@ case "$1" in
sleep "$MF_SLEEP"
done
esac
# curl --request PUT --header "X-Auth-Token: hLPp23gO8QeZWPYXXXXXXXMs0jG0XTYgNZBgRA=" --header "Content-Type: application/json" --data '{"entry_ids":[388229, 388211], "status":"read"}' https://miniflux.mgrote.net/v1/entries
lese suchwörter per feedurl ein
suche pro feed url nach suchwortern
markiere als gelesen
get all feeds where are unread entries+
check if for that feeds a filter is defined
search for keywords for this feedsunread entries
mark entries as read
token: hLPp23gO8QeZWPYzK3jYgmGbABvMs0jG0XTYgNZBgRA= # später tauschen
curl -H "X-Auth-Token: hLPp23gO8QeZWPYzK3jYgmGbABvMs0jG0XTYgNZBgRA=" https://miniflux.mgrote.net/v1/me
#!/bin/bash
# get all feeds where are unread entries+
token="X-Auth-Token: hLPp23gO8QeZWPYzK3jYgmGbABvMs0jG0XTYgNZBgRA="
url="https://miniflux.mgrote.net/v1/"
for feed in $(curl --silent -H $token $url/feeds | jq .[].id) ; do
unread_entries=$(curl --silent -H $token $url/feeds/$feed/entries?status=unread)
done
----
#!/bin/bash
# get all feeds where are unread entries+
MF_FILTERLIST="
golem.de::Anzeige
golem.de::Aus dem Verlag:
golem.de::Elon Musk
golem.de::Fifa
golem.de::Fussball
golem.de::Fußball
golem.de::(g+)
"
token="X-Auth-Token: hLPp23gO8QeZWPYzK3jYgmGbABvMs0jG0XTYgNZBgRA="
url="https://miniflux.mgrote.net/v1"
# für jeden feed
for feed in $(curl --silent -H "$token" "$url/feeds" | jq .[].id) ; do
echo for1
unread_entries=$(curl --silent -H "$token" "$url/feeds/$feed/entries?status=unread" | jq .total)
# der ungelesen einträge hat
if [[ $unread_entries -gt 0 ]] ; then
echo if1
fi
done
echo "$MF_FILTERLIST" | while read -r line ; do
echo while1
filter_url=$(echo "$line" | tr '[:upper:]' '[:lower:]' | awk --field-separator="::" '{print $1}')
echo $filter_url
mf_site_url=$(curl --silent -H "$token" "$url/feeds/$feed" | jq --raw-output .site_url)
echo $mf_site_url
# prufe ob ein filter dafur existiert
echo "$filter_url" | grep "$mf_site_url"
if [[ $(echo "$filter_url" | grep --silent "$mf_site_url") ]] ; then
echo for2
echo "id: $feed"
echo "$mf_site_url $filter_url"
fi
done