Last active
December 3, 2020 20:33
-
-
Save wormyrocks/29680677e01fe0369e350642e8f6dca8 to your computer and use it in GitHub Desktop.
Read pledge and backer data from Kickstarter's public API in real time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Track a Kickstarter page in real time | |
# License: https://raw.githubusercontent.com/Zuph/ACAB-License/master/LICENSE.md/LICENSE.md | |
# Github Gists don't preserve file permissions - check the comments on this page | |
# for a downloadable copy of this script whose permissions have already been set. | |
interval=5 # refresh interval in seconds | |
url="https://www.kickstarter.com/projects/lookingglass/looking-glass-portrait/stats.json" | |
[[ -z $1 ]] && { | |
command -v watch >/dev/null && { watch -t -d -n $interval "$0 ${url}"; exit 0; } || { clear; while true; do echo -e "`$0 ${url}`"; printf "\033[0;0H"; sleep $interval; done } | |
} || | |
data=$(curl $url 2> /dev/null ) | |
backers=$(echo -e $data | sed 's|.*backers_count":\([0-9]*\),.*|\1|') | |
comments=$(echo -e $data | sed 's|.*comments_count":\([0-9]*\),.*|\1|') | |
pledged_=$(echo -e $data | sed 's|.*pledged":"\([0-9.]*\).*|\1|') | |
pledged=$(LC_ALL=en_US.UTF-8 printf "%'.2f\n" $pledged_) | |
echo we raised \$$pledged from $backers backers with $comments comments. | |
echo $backers >> /tmp/.log_backers | |
echo $pledged_ >> /tmp/.log_raised | |
echo $comments >> /tmp/.log_comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download links with permissions and extensions pre-set, for the shell-averse:
macOS -> https://ufile.io/9v93sv1w
Windows/Linux -> https://ufile.io/79etrjyt
Usage on Windows depends on Git Bash being installed: https://gitforwindows.org/