summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-08-14 00:21:24 +0100
committerKatolaZ <katolaz@freaknet.org>2018-08-14 00:21:24 +0100
commit5e9fde247d04ad621f5883e57e9a4d0574737209 (patch)
treec540cab533714ebfd9ba34e47a60af771d739e9e
initial commit -- bbc_news onlyHEADmaster
-rwxr-xr-xbbc_news37
1 files changed, 37 insertions, 0 deletions
diff --git a/bbc_news b/bbc_news
new file mode 100755
index 0000000..11d04d6
--- /dev/null
+++ b/bbc_news
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+
+##
+##
+## Create an index in .gph format from a BBC news feed
+##
+##
+
+##IPREFIX="/tmp/rss_$$"
+IPREFIX="tmp_$$"
+INF="$1"
+
+
+## function
+to_gph(){
+
+ text=$(xml2 < "$1")
+ title=$(echo "$text" | grep "^/item/title=" | cut -d "=" -f 2)
+ descr=$(echo "$text" | grep "^/item/description=" | cut -d "=" -f 2 )
+ link=$(echo "$text" | grep "^/item/link=" | cut -d "=" -f 2)
+ news_time=$(echo "$text" | grep "^/item/pubDate=" | cut -d "=" -f 2)
+
+ printf "[i| |Err|server|port]\r\n"
+ printf "[h|${news_time} ${title}|URL:${link}|server|port]\r\n"
+ printf "[i|${descr}|Err|server|port]\r\n"
+
+}
+
+
+num=$(curl -s "$INF" | csplit -f ${IPREFIX} - '/<item>/' '{*}' | wc -l)
+
+for i in $(seq -w 1 $(($num - 1))); do
+ to_gph ${IPREFIX}${i}
+done
+
+