diff --git a/wolfpack b/wolfpack index ec51d59..582e49c 100755 --- a/wolfpack +++ b/wolfpack @@ -155,22 +155,25 @@ function download { echo "Need a valid argument." return; fi + export dedupterm="$(echo $1 | rev | cut -f 1 -d '/' | rev | cut -f 1 -d '.')" # Second line in the file is the directory to download to. - export downloaddir=$(head -n 2 "$1" | tail -n 1) + export downloaddir=$(head -n 2 "$1" | tail -n 1 | sed 's#/$##') # The third line and any following lines should be for i in $(tail -n +3 "$1"); do if [ -z "$i" ]; then continue; fi export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -) export nexturl=$(bash -c "$comm") done + if [ -z "$nexturl" ]; then + echo ERR: $dedupterm wolf pup is not finding its target. + fi export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)" #if file doesn't already exist.... if [ ! -f "$filename" ]; then echo Downloading $nexturl to $filename ... | tee -a "$logfile" - export dedupterm="$(echo $1 | rev | cut -f 1 -d '/' | rev | cut -f 1 -d '.')" for i in $(find "$downloaddir" -type f | grep -i "$dedupterm"); do - echo Deduped! Removed $i from $downloaddir | tee -a "$logfile" - rm -f "$downloaddir"/"$i" 2>&1 | tee -a "$logfile" + echo Deduped\! Removed $i from $downloaddir | tee -a "$logfile" + rm -f "$i" 2>&1 | tee -a "$logfile" done wget --timeout=5 -q -O "$filename" "$nexturl" echo Downloaded | tee -a "$logfile" @@ -183,7 +186,7 @@ function search { echo "Need a valid argument." return; fi - export downloaddir=$(head -n 2 "$1" | tail -n 1) + export downloaddir=$(head -n 2 "$1" | tail -n 1 | sed 's#/$##') for i in $(tail -n +3 "$1"); do export searchstring=$(echo $i | sed 's/ /+/g') export file="$downloaddir"/$searchstring'.txt'