diff options
-rwxr-xr-x | runsfeed | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/runsfeed b/runsfeed index 3fc6ee6..0db2bac 100755 --- a/runsfeed +++ b/runsfeed | |||
@@ -21,35 +21,41 @@ main() { | |||
21 | export sfeedpath="$SFEED_DATA/feeds" | 21 | export sfeedpath="$SFEED_DATA/feeds" |
22 | test -d "$(dirname "$sfeedrc")" || mkdir -p "$(dirname "$sfeedrc")" | 22 | test -d "$(dirname "$sfeedrc")" || mkdir -p "$(dirname "$sfeedrc")" |
23 | test -d "$sfeedpath" || mkdir -p "$sfeedpath" | 23 | test -d "$sfeedpath" || mkdir -p "$sfeedpath" |
24 | touch /tmp/runsfeed.ok | ||
24 | 25 | ||
25 | if ! $NOFETCH; then | 26 | if ! $NOFETCH; then |
26 | log Finding Invidious host... | 27 | logok "Finding Invidious host" \ |
27 | get_invidious_url "https://api.invidious.io/instances.json?sort_by=health" | 28 | get_invidious_url "https://api.invidious.io/instances.json?sort_by=health" |
28 | fi | 29 | fi |
29 | log Removing unsubscribed feeds... | 30 | logok "Removing unsubscribed feeds" \ |
30 | remove_unsubs "$sfeedrc" | 31 | remove_unsubs "$sfeedrc" |
31 | log Updating feeds... | 32 | logok -n "Updating feeds" \ |
32 | update "$sfeedrc" | 33 | update "$sfeedrc" |
33 | log Updating urls... | 34 | logok "Updating urls" \ |
34 | update_urls "$sfeedrc" | 35 | update_urls "$sfeedrc" |
35 | log Generating HTML... | 36 | logok "Generating HTML" '{ |
36 | html "$sfeedpath"/* >/tmp/sfeed-index.html && | 37 | html "$sfeedpath"/* >/tmp/sfeed-index.html && |
37 | mv /tmp/sfeed-index.html "$SFEED_OUTPUT/index.html" | 38 | mv /tmp/sfeed-index.html "$SFEED_OUTPUT/index.html"; |
38 | log | 39 | LIMIT=0 html "$sfeedpath"/* >/tmp/sfeed-feeds.html && |
39 | LIMIT=0 html "$sfeedpath"/* >/tmp/sfeed-feeds.html && | 40 | mv /tmp/sfeed-feeds.html "$SFEED_OUTPUT/feeds.html"; |
40 | mv /tmp/sfeed-feeds.html "$SFEED_OUTPUT/feeds.html" | 41 | }' |
41 | log | 42 | logok "Generating RSS" '{ |
42 | log Generating RSS... | 43 | atom "$sfeedpath" >/tmp/feeds.xml && |
43 | atom "$sfeedpath" >/tmp/feeds.xml && | 44 | mv /tmp/feeds.xml "$SFEED_OUTPUT/feeds.xml"; |
44 | mv /tmp/feeds.xml "$SFEED_OUTPUT/feeds.xml" | 45 | atom "$sfeedpath" 7 >/tmp/feeds-short.xml && |
45 | atom "$sfeedpath" 7 >/tmp/feeds-short.xml && | 46 | mv /tmp/feeds-short.xml "$SFEED_OUTPUT/feeds-short.xml"; |
46 | mv /tmp/feeds-short.xml "$SFEED_OUTPUT/feeds-short.xml" | 47 | }' |
47 | log Generating OPML... | 48 | logok "Generating OPML" '{ |
48 | opml "$sfeedrc" >/tmp/feeds.opml && | 49 | opml "$sfeedrc" >/tmp/feeds.opml && |
49 | mv /tmp/feeds.opml "$SFEED_OUTPUT/feeds.opml" | 50 | mv /tmp/feeds.opml "$SFEED_OUTPUT/feeds.opml"; |
50 | # log Archiving old feeds... | 51 | }' |
52 | # logok "Archiving old feeds" \ | ||
51 | # archive "$sfeedpath"/* | 53 | # archive "$sfeedpath"/* |
52 | log Done. | 54 | if [ -f /tmp/runsfeed.ok ]; then |
55 | echo >&2 'Done.' | ||
56 | else | ||
57 | echo >&2 'Done (some errors).' | ||
58 | fi | ||
53 | } | 59 | } |
54 | 60 | ||
55 | runcmd() { | 61 | runcmd() { |
@@ -74,8 +80,22 @@ get_invidious_url() { | |||
74 | head -n1 | tee /tmp/invidious.host | 80 | head -n1 | tee /tmp/invidious.host |
75 | } | 81 | } |
76 | 82 | ||
77 | log() { | 83 | logok() { |
78 | printf '%s\n' "$*" >&2 | 84 | newline='' |
85 | if [ "x$1" = x-n ]; then | ||
86 | newline='\n' | ||
87 | shift | ||
88 | fi | ||
89 | printf "%s...$newline" "$1" >&2 | ||
90 | shift | ||
91 | if output="$(eval "$@" | tee /dev/stderr)"; then | ||
92 | printf '%s\n' "${output:-ok}" | ||
93 | return 0 | ||
94 | else | ||
95 | rm /tmp/runsfeed.ok | ||
96 | printf 'ERROR\n' | ||
97 | return 1 | ||
98 | fi | ||
79 | } | 99 | } |
80 | 100 | ||
81 | update() { | 101 | update() { |