]> gitweb.fluxo.info Git - httruta.git/commitdiff
Support for getting URLs from file
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 28 Oct 2013 17:15:38 +0000 (15:15 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 28 Oct 2013 17:15:38 +0000 (15:15 -0200)
httracker

index 7fc33c17b656d7f0e29f4987cc489afced022e54..f899f0698655bf6028353e8a009b9bc493ce4602 100755 (executable)
--- a/httracker
+++ b/httracker
@@ -6,13 +6,25 @@
 # Load and initialize
 source `dirname $0`/lib/httracker/functions || exit 1
 
-# Get URLs from feed
-# Thanks http://stackoverflow.com/questions/443991/how-to-parse-rss-feeds-xml-in-a-shell-script
-curl -s "$FEED" | grep -o '<link>[^<]*' | grep -o "[^>]*$" > $URLS
+# Parameters
+BASENAME="`basename $0`"
+FILE="$1"
 
-if [ "$?" != "0" ]; then
-  echo "Error downloading feed $FEED, aborting."
-  exit 1
+# Grab item list
+if [ -z "$FILE" ]; then
+  # Get URLs from feed
+  # Thanks http://stackoverflow.com/questions/443991/how-to-parse-rss-feeds-xml-in-a-shell-script
+  curl -s "$FEED" | grep -o '<link>[^<]*' | grep -o "[^>]*$" > $URLS
+
+  if [ "$?" != "0" ]; then
+    echo "Error downloading feed $FEED, aborting."
+    exit 1
+  fi
+elif [ -e "$FILE" ]; then
+  # Get URLs from file
+  cat $FILE > $URLS
+else
+  echo "usage: $BASENAME [file]"
 fi
 
 # Iterate over all URLs