Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [illwieckz:~/dev/unvanquished-download-counter] $ cat count
- #! /bin/sh
- getIndieDb () {
- curl -s "https://www.indiedb.com/games/${1}/stats" \
- | grep '<h5>Downloads Total</h5>' -A2 \
- | tail -n1 \
- | sed -e 's/[^0-9]*//g'
- }
- getGitHub () {
- curl -s https://api.github.com/repos/${1}/releases \
- | grep '"download_count":' \
- | sed -e 's/[^0-9]*//g' \
- | paste -s -d+ - \
- | bc
- }
- getSourceForge () {
- epoch="$(date '+%Y-%m-%d' -d@0)"
- today="$(date '+%Y-%m-%d')"
- curl -s "https://sourceforge.net/projects/${1}/files/stats/json?start_date=${epoch}&end_date=${today}" \
- | tr ',' '\n' \
- | grep '"time": {"downloads":' \
- | sed -e 's/[^0-9]*//g'
- }
- getSum () {
- echo "${@}" \
- | tr ' ' '\n' \
- | paste -s -d+ - \
- | bc
- }
- indiedb_all="$(getIndieDb 'unvanquished')"
- github_game="$(getGitHub 'Unvanquished/Unvanquished')"
- github_updater="$(getGitHub 'Unvanquished/updater')"
- sourceforge_all="$(getSourceForge 'unvanquished')"
- sum_all="$(getSum "${indiedb_all}" "${github_game}" "${github_updater}" "${sourceforge_all}")"
- cat <<EOF
- {
- {
- "description": "Unvanquished game on GitHub",
- "proof-url": "https://www.somsubhra.com/github-release-stats/?username=Unvanquished&repository=Unvanquished",
- "key": "github/game",
- "count": ${github_game},
- },
- {
- "description": "Unvanquished updater on GitHub",
- "proof-url": "https://www.somsubhra.com/github-release-stats/?username=Unvanquished&repository=updater",
- "key": "github/updater",
- "count": ${github_updater},
- },
- {
- "description": "Unvanquished files on SourceForge",
- "proof-url": "https://sourceforge.net/projects/unvanquished/files/stats/timeline?dates=2012-02-26+to+2019-05-28",
- "key": "sourceforge/all",
- "count": ${sourceforge_all},
- },
- {
- "description": "Unvanquished files on Indie DB",
- "proof-url": "https://www.indiedb.com/games/unvanquished/stats",
- "key": "indiedb/game",
- "count": ${indiedb_all},
- },
- {
- "description": "Unvanquished files total"
- "key": "summary"
- "count": "${sum_all}"
- }
- }
- EOF
- #EOF
- [illwieckz:~/dev/unvanquished-download-counter] $ ./count
- {
- {
- "description": "Unvanquished game on GitHub",
- "proof-url": "https://www.somsubhra.com/github-release-stats/?username=Unvanquished&repository=Unvanquished",
- "key": "github/game",
- "count": 24500,
- },
- {
- "description": "Unvanquished updater on GitHub",
- "proof-url": "https://www.somsubhra.com/github-release-stats/?username=Unvanquished&repository=updater",
- "key": "github/updater",
- "count": 3313,
- },
- {
- "description": "Unvanquished files on SourceForge",
- "proof-url": "https://sourceforge.net/projects/unvanquished/files/stats/timeline?dates=2012-02-26+to+2019-05-28",
- "key": "sourceforge/all",
- "count": 1337688,
- },
- {
- "description": "Unvanquished files on Indie DB",
- "proof-url": "https://www.indiedb.com/games/unvanquished/stats",
- "key": "indiedb/game",
- "count": 2969,
- },
- {
- "description": "Unvanquished files total"
- "key": "summary"
- "count": "1368470"
- }
- }
Add Comment
Please, Sign In to add comment