Added test to download from brickinstructions if lego.com is unavailable
This commit is contained in:
parent
affb4bb441
commit
68ddb6bf86
21
lego_dl.sh
21
lego_dl.sh
@ -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')
|
#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
|
if [ -z "$ttDESC" ]; then
|
||||||
setDESC="_"
|
etDESC="_"
|
||||||
else
|
else
|
||||||
setDESC="_("$ttDESC")_"
|
tDESC="_("$ttDESC")_"
|
||||||
fi
|
fi
|
||||||
#PC=$(echo $CURRENT $LINES | awk '{print 100*$1/$2}')
|
#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
|
filename=$tFilename
|
||||||
|
|
||||||
if [ -f "$downloadFolder/$filename" ]; then
|
if [ -f "$downloadFolder/$filename" ]; then
|
||||||
@ -124,10 +124,9 @@
|
|||||||
else
|
else
|
||||||
if [[ "$tDESC" = "{No longer listed at LEGO.com}" ]] ; then
|
if [[ "$tDESC" = "{No longer listed at LEGO.com}" ]] ; then
|
||||||
echo -ne "-> $tID testing link."
|
echo -ne "-> $tID testing link."
|
||||||
|
echo -ne "LEGO.com <$tLINK>..."
|
||||||
if validate_url $tLINK; then
|
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"
|
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
|
if [ -f "$downloadFolder/$filename" ]; then
|
||||||
echo "Done! > $filename"
|
echo "Done! > $filename"
|
||||||
@ -142,8 +141,11 @@
|
|||||||
sleep $(( ( RANDOM % 5 ) + 1 ))
|
sleep $(( ( RANDOM % 5 ) + 1 ))
|
||||||
else
|
else
|
||||||
#test
|
#test
|
||||||
|
|
||||||
|
biID=$(sed -e 's/[^0-9_]/_/g' <<< $tID)
|
||||||
biLink="https://lego.brickinstructions.com/pdfdrop/"
|
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..."
|
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"
|
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
|
if [ -f "$downloadFolder/$filename" ]; then
|
||||||
@ -157,14 +159,14 @@
|
|||||||
fi
|
fi
|
||||||
#random sleep in order to not look like a script
|
#random sleep in order to not look like a script
|
||||||
sleep $(( ( RANDOM % 5 ) + 1 ))
|
sleep $(( ( RANDOM % 5 ) + 1 ))
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ $error_level = 1 || $error_level = 2 ]]; then
|
if [[ $error_level = 1 || $error_level = 2 ]]; then
|
||||||
echo "-> $tID is not available. Skipping..."
|
echo "-> $tID is not available. Skipping..."
|
||||||
echo "$filename is not available." >> $logfile
|
echo "$filename is not available." >> $logfile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -ne "--> $tID downloading now..."
|
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"
|
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
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < instructions.csv
|
done < instructions.csv
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user