sfeed_gopher_categories.sh - randomcrap - random crap programs of varying quality
HTML git clone git://git.codemadness.org/randomcrap
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
sfeed_gopher_categories.sh (1115B)
---
1 #!/bin/sh
2
3 feed() {
4 echo "$category $1"
5 }
6
7 SFEED_GOPHER_HOST="codemadness.org"
8 SFEED_GOPHER_PORT="70"
9
10 prevcat=""
11 IFS=" "
12 LC_CTYPE="C"
13 (category=""
14 . ~/.sfeed/sfeedrc
15 feeds
16
17 category=""
18 . ~/.sfeed/sfeedrc.daily
19 feeds) | \
20 sort -k1,1 -k2,2 | \
21 while read -r cat feed; do
22
23 # hack: count new
24 # NOTE: change to feed dir.
25 #file="$HOME/.sfeed/feeds/$feed"
26 file="$HOME/.sfeed/thisweek/$feed"
27 # file must exists and be non-zero filesize.
28 test -s "$file" || continue
29
30 if test x"$prevcat" != x"$cat"; then
31 printf 'i\t\t%s\t%s\r\n' "$SFEED_GOPHER_HOST" "$SFEED_GOPHER_PORT"
32 printf 'i\t\t%s\t%s\r\n' "$SFEED_GOPHER_HOST" "$SFEED_GOPHER_PORT"
33 printf 'i%s\t\t%s\t%s\r\n' "$cat" "$SFEED_GOPHER_HOST" "$SFEED_GOPHER_PORT"
34 fi
35
36 new=$(cat "$file" 2>/dev/null | sfeed_plain | awk 'BEGIN { lines = 0; } /^N/ { lines++; } END { print lines; }')
37 total=$(wc -l < "$file" | tr -d ' ' 2>/dev/null)
38 icon=" "
39 if test x"$new" != x"0"; then
40 icon="N"
41 fi
42 printf '1%s %s (%s/%s)\t/feeds/%s\t%s\t%s\r\n' "$icon" "$feed" "$new" "$total" "$feed" "$SFEED_GOPHER_HOST" "$SFEED_GOPHER_PORT"
43
44 prevcat="$cat"
45 done
46
47 printf ".\r\n"