Dedup and error checking fix for download pups
This commit is contained in:
parent
bc91ff224b
commit
742a58d2c2
13
wolfpack
13
wolfpack
@ -155,22 +155,25 @@ function download {
|
|||||||
echo "Need a valid argument."
|
echo "Need a valid argument."
|
||||||
return;
|
return;
|
||||||
fi
|
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.
|
# 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
|
# The third line and any following lines should be
|
||||||
for i in $(tail -n +3 "$1"); do
|
for i in $(tail -n +3 "$1"); do
|
||||||
if [ -z "$i" ]; then continue; fi
|
if [ -z "$i" ]; then continue; fi
|
||||||
export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -)
|
export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -)
|
||||||
export nexturl=$(bash -c "$comm")
|
export nexturl=$(bash -c "$comm")
|
||||||
done
|
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)"
|
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
|
||||||
#if file doesn't already exist....
|
#if file doesn't already exist....
|
||||||
if [ ! -f "$filename" ]; then
|
if [ ! -f "$filename" ]; then
|
||||||
echo Downloading $nexturl to $filename ... | tee -a "$logfile"
|
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
|
for i in $(find "$downloaddir" -type f | grep -i "$dedupterm"); do
|
||||||
echo Deduped! Removed $i from $downloaddir | tee -a "$logfile"
|
echo Deduped\! Removed $i from $downloaddir | tee -a "$logfile"
|
||||||
rm -f "$downloaddir"/"$i" 2>&1 | tee -a "$logfile"
|
rm -f "$i" 2>&1 | tee -a "$logfile"
|
||||||
done
|
done
|
||||||
wget --timeout=5 -q -O "$filename" "$nexturl"
|
wget --timeout=5 -q -O "$filename" "$nexturl"
|
||||||
echo Downloaded | tee -a "$logfile"
|
echo Downloaded | tee -a "$logfile"
|
||||||
@ -183,7 +186,7 @@ function search {
|
|||||||
echo "Need a valid argument."
|
echo "Need a valid argument."
|
||||||
return;
|
return;
|
||||||
fi
|
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
|
for i in $(tail -n +3 "$1"); do
|
||||||
export searchstring=$(echo $i | sed 's/ /+/g')
|
export searchstring=$(echo $i | sed 's/ /+/g')
|
||||||
export file="$downloaddir"/$searchstring'.txt'
|
export file="$downloaddir"/$searchstring'.txt'
|
||||||
|
Loading…
Reference in New Issue
Block a user