Fixed errors

This commit is contained in:
Frederik Baerentsen 2020-06-24 10:18:54 +02:00
parent a848096baa
commit ec88a6914f

View File

@ -53,13 +53,19 @@ else
fi
fi
echo "----> Converting csv with ',' to '|'..."
head -1 instructions | sed 's/,/|/g' > instructions.csv
sed 1,1d instructions | sed -r 's/("[^",]+),([^",]+")/\1###\2/g' | awk -F, '{print $1,$2,$3,$4,$5,$6}' | sed 's/###/,/g' | sed 's/" "/"|"/g' >> instructions.csv
LINES=$(wc -l instructions | awk '{ print $1 }')
CURRENT=0
while IFS='|' read -r ID LINK NAME DESC ADDED RETRIVED
do
#$PC=$((200*$CURRENT/$LINES % 2 + 100*$CURRENT/$LINES))
#CURRENT=$((CURRENT + 1))
if [ "$firstline" = 0 ]; then
firstline=1
else
@ -89,14 +95,16 @@ do
tADDED=$(sed -e 's/^"//' -e 's/"$//' <<<"$ADDED")
tDESC=$(sed -e 's/^"//' -e 's/"$//' <<<"$DESC")
ttDESC=$(echo $tDESC | grep -Eo '\s[0-9]{1}\s?\/\s?[0-9]{1,2}' | sed 's/ //g' | sed 's/\//_of_/g')
ttDESC=$(echo $tDESC | grep -Eo '[^0-9][0-9]{1}\s?\/\s?[0-9]{1,2}' | sed 's/[^A-Za-z0-9/]//g' | sed 's/\//_of_/g')
#ttDESC=$(echo $tDESC | grep -Eo '\s[0-9]{1}\s?\/\s?[0-9]{1,2}' | sed 's/ //g' | sed 's/\//_of_/g')
if [ -z "$ttDESC" ]; then
setDESC="_"
else
setDESC="_("$ttDESC")_"
fi
#PC=$(echo $CURRENT $LINES | awk '{print 100*$1/$2}')
tFilename=""$tID""$setDESC""${setNAME// /_}"_("$setTHEME"_"$setYEAR").pdf"
filename=$tFilename
@ -119,13 +127,12 @@ do
else
echo "ERROR!"
if [[ $error_level = 1 || $error_level = 2 ]]; then
echo
echo "--> Not downloaded. Try again manually..."
echo "$filename was not downloaded. Check CURL" >> $logfile
fi
fi
#random sleep in order to not look like a script
sleep $(( ( RANDOM % 1 ) + 1 ))
sleep $(( ( RANDOM % 5 ) + 1 ))
fi
fi
fi
fi