Skip to content

Instantly share code, notes, and snippets.

@simonjenny
Last active January 9, 2020 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonjenny/f19776ffb6a9afc266a79b502813a4bf to your computer and use it in GitHub Desktop.
Save simonjenny/f19776ffb6a9afc266a79b502813a4bf to your computer and use it in GitHub Desktop.
Find Lego building instructions by set number from the command line and open the PDF in the default browser
#!/usr/bin/env bash
ARRAY=()
var=1
rows=$(curl --silent "https://www.lego.com//service/biservice/search?fromIndex=0&locale=en-US&onlyAlternatives=false&prefixText=${1}"|jq -r '.products[0].buildingInstructions[].pdfLocation')
for row in $rows;
do
ARRAY+=(${row})
echo "$((var++)). ${row}"
done
echo -ne "Welche Anleitung soll ich öffnen? "
read n
URL="${ARRAY[n-1]}"
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open || which open) && exec "$path" "$URL"
@simonjenny
Copy link
Author

Usage : ./lego.sh SETNUMBER
Example :
./lego.sh 70321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment