Skip to content

Instantly share code, notes, and snippets.

@bzikarsky
Created January 23, 2017 11:07
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 bzikarsky/cea9eebd973c7ec52f9228065fcbe1d2 to your computer and use it in GitHub Desktop.
Save bzikarsky/cea9eebd973c7ec52f9228065fcbe1d2 to your computer and use it in GitHub Desktop.
Desperate measures for ordering a OnePlus 3T )
#!/bin/bash
# Check for availability of a OnePlus stock item (405 == OnePlus 3T 128GB EU)
# and notify over pushover.net
#
# Background: https://www.oneplusstock.net/ revealed that you do not get
# an instant notification as soon as it goes back on stock...so this might
# help...
#
# Use with pushover command-line utility (`pip install pushover-python`)
# as a cronjob script with an interval of your choice
STORE="de"
ID=405
URL="https://oneplus.net/xman/product/info?param=%7B%22store%22%3A%22$STORE%22%2C%22id%22%3A409%2C%22ids%22%3A%5B%22$ID%22%5D%7D"
ITEM_INFO=$(curl -s $URL | jq -r ".data.children[\"$ID\"]")
ITEM_URL=$(echo $ITEM_INFO | jq -r '.targetLink')
ITEM_STOCK=$(echo $ITEM_INFO | jq -r '.stock')
ITEM_NAME=$(echo $ITEM_INFO | jq -r '.name')
if [ "0" != $ITEM_STOCK ]; then
MSG="$ITEM_NAME in stock! ($ITEM_STOCK)"
TITLE="OnePlus Stock notification"
pushover "$MSG" --title "$TITLE" --url "$ITEM_URL"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment