Skip to content

Instantly share code, notes, and snippets.

@RolandWarburton
Created August 5, 2019 23:46
Show Gist options
  • Save RolandWarburton/77084935fa2411aa2bfc09e5736670b1 to your computer and use it in GitHub Desktop.
Save RolandWarburton/77084935fa2411aa2bfc09e5736670b1 to your computer and use it in GitHub Desktop.
calculates total playtime from minecraft stats json data
#!/usr/bin/python3
import os
import json
__author__ = "Roland"
__version__ = "1.0.1"
def main():
# where to look for stats files
statsDir = '/home/roland/minecraft/world/stats'
# where to save the results
# total in secconds: 1 minecraft min = 0.83 irl secconds
total = 0.000
# change to the stats dir
os.chdir(statsDir)
for filename in os.listdir(statsDir):
f = open(filename,'r')
data = json.load(f)
total += data['stats']['minecraft:custom']['minecraft:play_one_minute']
# divide into irl secconds then convert to days.
# total/20/60 = irl mins
total = ((total/20)/60)/1440
# print('the total is: %d days' % (total) )
#outputFile = open("playtimeCounter.txt", "w")
#outputFile.write(str(total))
print(str(total))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment