Created
April 28, 2020 23:53
-
-
Save loudambiance/e1f5ac21226d2050d2791a2d91948ed1 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import urllib.request, json | |
from sys import argv | |
if(len(argv) > 1): | |
url = "https://bstats.org/api/v1/plugins/"+argv[1]+"/charts/servers/data" | |
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) | |
html = urllib.request.urlopen(req).read() | |
serversdata = json.loads(html.decode()) | |
#print(data) | |
serversize = len(serversdata) | |
servers = 0 | |
for val in serversdata: | |
if (servers < val[1]): | |
servers = val[1] | |
url = "https://bstats.org/api/v1/plugins/"+argv[1]+"/charts/players/data" | |
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) | |
html = urllib.request.urlopen(req).read() | |
playersdata = json.loads(html.decode()) | |
#print(data) | |
playersize = len(playersdata) | |
players = 0 | |
for val in playersdata: | |
if (players < val[1]): | |
players = val[1] | |
url = "https://bstats.org/api/v1/plugins/"+argv[1]+"/charts/pluginVersion/data" | |
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) | |
html = urllib.request.urlopen(req).read() | |
versionsdata = json.loads(html.decode()) | |
#print(data) | |
versionsize = len(versionsdata) | |
versionmax = 0 | |
versionsum = 0 | |
version = "0" | |
for val in versionsdata: | |
if (versionmax < val['y']): | |
versionmax = val['y'] | |
version = val['name'] | |
versionsum += val['y'] | |
print("Players: " + str(playersdata[playersize-1][1])+"/"+str(players)) | |
print("Servers: " + str(serversdata[serversize-1][1])+"/"+str(servers)) | |
print("Version: " + version +" "+ str(round((versionmax/versionsum)*100,2))+"%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment