Added test to download from brickinstructions if lego.com is unavailable

This commit is contained in:
Frederik Baerentsen 2020-06-25 18:14:25 +02:00
parent affb4bb441
commit 68ddb6bf86

View File

@ -108,12 +108,12 @@
#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="_"
etDESC="_"
else
setDESC="_("$ttDESC")_"
tDESC="_("$ttDESC")_"
fi
#PC=$(echo $CURRENT $LINES | awk '{print 100*$1/$2}')
tFilename=""$tID""$setDESC""${setNAME// /_}"_("$setTHEME"_"$setYEAR").pdf"
tFilename=""$tID"_"$setDESC""${setNAME// /_}"_("$setTHEME"_"$setYEAR").pdf"
filename=$tFilename
if [ -f "$downloadFolder/$filename" ]; then
@ -124,10 +124,9 @@
else
if [[ "$tDESC" = "{No longer listed at LEGO.com}" ]] ; then
echo -ne "-> $tID testing link."
echo -ne "LEGO.com <$tLINK>..."
if validate_url $tLINK; then
echo -ne "Found... Downloading..."
echo -ne "Found on lego.com... Downloading..."
curl -H "Mozilla/5.0 (platform; rv:75.0) Gecko/20100101 Firefox/75.0" -L $tLINK --silent --output "$downloadFolder/$filename"
if [ -f "$downloadFolder/$filename" ]; then
echo "Done! > $filename"
@ -142,8 +141,11 @@
sleep $(( ( RANDOM % 5 ) + 1 ))
else
#test
biID=$(sed -e 's/[^0-9_]/_/g' <<< $tID)
biLink="https://lego.brickinstructions.com/pdfdrop/"
if validate_url "$biLink$tID.pdf"; then
echo -ne "BrickInstructions <$biLink$biID.pdf>..."
if validate_url "$biLink$biID.pdf"; then
echo -ne "Found on BrickInstructions... Downloading..."
curl -H "Mozilla/5.0 (platform; rv:75.0) Gecko/20100101 Firefox/75.0" -L "$biLink$tID.pdf" --silent --output "$downloadFolder/$filename"
if [ -f "$downloadFolder/$filename" ]; then
@ -157,14 +159,14 @@
fi
#random sleep in order to not look like a script
sleep $(( ( RANDOM % 5 ) + 1 ))
fi
fi
else
if [[ $error_level = 1 || $error_level = 2 ]]; then
echo "-> $tID is not available. Skipping..."
echo "$filename is not available." >> $logfile
fi
fi
fi
else
echo -ne "--> $tID downloading now..."
curl -H "Mozilla/5.0 (platform; rv:75.0) Gecko/20100101 Firefox/75.0" -L $tLINK --silent --output "$downloadFolder/$filename"
@ -182,6 +184,5 @@
fi
fi
fi
done < instructions.csv