From affb4bb4418cf6673147ced9e562ea431df3e558 Mon Sep 17 00:00:00 2001 From: Frederik Baerentsen Date: Thu, 25 Jun 2020 15:56:06 +0200 Subject: [PATCH] Added test to download from brickinstructions if lego.com is unavailable --- lego_dl.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lego_dl.sh b/lego_dl.sh index 249f612..e39701f 100644 --- a/lego_dl.sh +++ b/lego_dl.sh @@ -134,13 +134,31 @@ else echo "ERROR!" if [[ $error_level = 1 || $error_level = 2 ]]; then - echo "--> Not downloaded. Try again manually..." - echo "$filename was not downloaded. Check CURL" >> $logfile + 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 % 5 ) + 1 )) - fi - + else + #test + biLink="https://lego.brickinstructions.com/pdfdrop/" + if validate_url "$biLink$tID.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 + echo "Done! > $filename" + else + echo "ERROR!" + if [[ $error_level = 1 || $error_level = 2 ]]; then + 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 % 5 ) + 1 )) + fi + fi else if [[ $error_level = 1 || $error_level = 2 ]]; then echo "-> $tID is not available. Skipping..."