Guest User

Untitled

a guest
Nov 26th, 2020
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. import re
  3. import time
  4. import sys
  5. import os
  6. import threading
  7. import datetime
  8. import calendar
  9. from progress.spinner import Spinner
  10. from sty import fg, bg, ef, rs
  11. from sty import Style, RgbFg
  12.  
  13. fg.redder = Style(RgbFg(255,60,60))
  14. os.system('cls' if os.name == 'nt' else 'clear')
  15. print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  16.  
  17. SID64 = input("Enter SteamID64: ")
  18. SIDhash = '#' + SID64
  19.  
  20. try:
  21.     SID3 = 'U:1:' + (str(int(SID64) - 76561197960265728))
  22. except ValueError:
  23.     print('\nInputted Steam ID was not an Integer.')
  24.     input('\n\nPress Enter to Quit...')
  25.     sys.exit()
  26.    
  27. logs_prof = 'https://logs.tf/profile/' + SID64
  28. logs = requests.get(logs_prof).text
  29.  
  30. results = re.search('<p>(.*?)</p>', logs)
  31. p_name = re.search('<title>(.*?)</title>', logs)
  32.  
  33. try:
  34.     log_count = int(''.join(i for i in results.group(1) if i.isdigit()))
  35.     if log_count > 10000:
  36.         log_count = 10000
  37. except:
  38.     print('\nInvald Steam ID or No Logs on Account.')
  39.     input('\n\nPress Enter to Quit...')
  40.     sys.exit()
  41.  
  42. if log_count > 25:
  43.     total_pages = int(log_count / 25) + 1
  44. else:
  45.     total_pages = 1
  46.  
  47. print('\n\n' + str(total_pages) + ' Pages and ' + str(log_count) + ' Logs Found for Player: ' + p_name.group(1)[:-10])
  48.  
  49. def create_dates():
  50.     global start_date_lst_int
  51.     global end_date_lst_int
  52.     global curdate
  53.     global end_date_epoch
  54.     global start_date_epoch
  55.     global firstdate
  56.     start_date_lst_int = None
  57.     end_date_lst_int = None
  58.     curdate = None
  59.     end_date_epoch = None
  60.     start_date_epoch = None
  61.     firstdate = False
  62. def create_variables():
  63.  
  64.     global mercenary_dic
  65.     global gamemode_dic
  66.     global gamemode_printed
  67.    
  68.     gamemode_printed = False
  69.  
  70.     mercenary_dic = {
  71.     '1' : '[ 1 ] Scout',
  72.     '2' : '[ 2 ] Soldier',
  73.     '3' : '[ 3 ] Pyro',
  74.     '4' : '[ 4 ] Demoman',
  75.     '5' : '[ 5 ] Heavy',
  76.     '6' : '[ 6 ] Engineer',
  77.     '7' : '[ 7 ] Medic',
  78.     '8' : '[ 8 ] Sniper',
  79.     '9' : '[ 9 ] Spy'
  80.     }
  81.        
  82.     gamemode_dic = {
  83.     '1' : '[ 1 ] Sixes',
  84.     '2' : '[ 2 ] Highlander',
  85.     '3' : '[ 3 ] Prolander',
  86.     '4' : '[ 4 ] Fours',
  87.     '5' : '[ 5 ] Bball / Ultiduo'
  88.     }
  89.        
  90. create_variables()
  91. create_dates()
  92.  
  93. def print_sorter(string):
  94.     string1 = ''
  95.     for i in string:
  96.         if i in map(chr, range(97, 123)) or i in map(chr, range(65, 91)) or i == ' ' or i == '/':
  97.             string1 += i
  98.     string2 = string1.split('   ')
  99.     for i in string2:
  100.         if i == '':
  101.             string2.remove(i)
  102.     string3 = [x.strip(' ') for x in string2]
  103.     return (', '.join(string3))
  104.    
  105. def ask_filter_input():
  106.     global filter_input
  107.     filter_input = input('Would you like to filter your search? (y/n)\n> ')
  108.     if filter_input not in ['y', 'n']:
  109.         ask_filter_input()
  110. ask_filter_input()
  111.  
  112. if filter_input == 'y':
  113.    
  114.     class Daterange:
  115.            
  116.         @classmethod
  117.         def daterangeerror(cls, error_code):
  118.             os.system('cls' if os.name == 'nt' else 'clear')
  119.             print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  120.             print('\nError occured while inputting dates.')
  121.             if error_code == 1:
  122.                 print('Error Message - Invalid End Date Input.')
  123.             if error_code == 2:
  124.                 print('Error Message - Start Date cannot be later than End Date.')
  125.             if error_code == 3:
  126.                 print('Error Message - Invalid Start Date Input.')
  127.             create_dates()
  128.             exittomenu()
  129.            
  130.         @classmethod
  131.         def daterangeend(cls):
  132.             global end_date_epoch
  133.             global end_date_lst_int
  134.             global curdate
  135.             global firstdate
  136.             print('Enter an End Date (leave blank for current date):')
  137.             end_date_inp = input('\n> ')
  138.             if not end_date_inp:
  139.                 end_date_epoch = time.time()
  140.                 curdate = time.strftime("%m-%d-%Y").split('-')
  141.                 print('Date Range Successfully Defined.')
  142.                 exittomenu()
  143.                 return
  144.             end_date_lst_str = end_date_inp.split('/')
  145.             try:
  146.                 end_date_lst_int = list(map(int, end_date_lst_str))
  147.                 end_date_epoch = int(datetime.datetime(end_date_lst_int[-1],end_date_lst_int[-3],end_date_lst_int[-2]).timestamp())
  148.             except:
  149.                 cls.daterangeerror(1)
  150.                 return
  151.            
  152.             if not firstdate:
  153.                 if (start_date_epoch > end_date_epoch):
  154.                     cls.daterangeerror(2)
  155.             print('Date Range Successfully Defined.')
  156.             exittomenu()
  157.            
  158.         @classmethod
  159.         def daterangestart(cls):
  160.             global start_date_lst_int
  161.             global start_date_epoch
  162.             global firstdate
  163.             os.system('cls' if os.name == 'nt' else 'clear')
  164.             print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  165.             print("Enter a Start Date. \nExample: 6/30/2015 = June 30, 2015 (leave blank for first log's date):")
  166.             start_date_inp = input('\n> ')
  167.             if not start_date_inp:
  168.                 start_date_epoch = 'first'
  169.                 firstdate = True
  170.                 cls.daterangeend()
  171.                 return
  172.             start_date_lst_str = start_date_inp.split('/')
  173.             try:
  174.                 start_date_lst_int = list(map(int, start_date_lst_str))
  175.                 start_date_epoch = int(datetime.datetime(start_date_lst_int[-1],start_date_lst_int[-3],start_date_lst_int[-2]).timestamp())
  176.             except:
  177.                 cls.daterangeerror(3)
  178.             if start_date_epoch > time.time():
  179.                 cls.daterangeerror(2)
  180.             else:
  181.                 cls.daterangeend()
  182.            
  183.        
  184.    
  185.     class Gamemode:
  186.  
  187.             @classmethod
  188.             def gamemode_error(cls, error_code):
  189.                 os.system('cls' if os.name == 'nt' else 'clear')
  190.                 print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  191.                 print('\nError occured while filtering gamemodes.')
  192.                 if error_code == 1:
  193.                     print('Error Message - Gamemode List cannot be empty. List has been reset.')
  194.                 if error_code == 2:
  195.                     print('Error Message - Gamemode List removal selection out of range. List has been reset.')
  196.                 exittomenu()
  197.                
  198.             @classmethod
  199.             def gamemode_interface(cls):
  200.                 os.system('cls' if os.name == 'nt' else 'clear')
  201.                 print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  202.                 if all(value == '' for value in gamemode_dic.values()):
  203.                     cls.gamemode_error(1)
  204.                     return
  205.                 print('Iteration will show logs with these classes:')
  206.                 for display in gamemode_dic.values():
  207.                     print(display)
  208.                 gamemode_selection = input("\nTo REMOVE a gamemode: Pick 1 - 5 or leave blank to exit.\n> ")
  209.                 if not gamemode_selection:
  210.                     menu()
  211.                     return
  212.                 if gamemode_selection not in ['1', '2', '3', '4', '5']:
  213.                     cls.gamemode_interface()
  214.                     return
  215.                 else:
  216.                     gamemode_dic[gamemode_selection] = ''
  217.                     cls.gamemode_interface()
  218.                
  219.  
  220.     class Mercenary:
  221.  
  222.             @classmethod
  223.             def mercenary_error(cls, error_code):
  224.                 os.system('cls' if os.name == 'nt' else 'clear')
  225.                 print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  226.                 print('\nError occured while filtering classes.')
  227.                 if error_code == 1:
  228.                     print('Error Message - Class List cannot be empty. List has been reset.')
  229.                 if error_code == 2:
  230.                     print('Error Message - Class List removal selection out of range. List has been reset.')
  231.                 exittomenu()
  232.                
  233.             @classmethod
  234.             def mercenary_interface(cls):
  235.                 os.system('cls' if os.name == 'nt' else 'clear')
  236.                 print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  237.                 if all(value == '' for value in mercenary_dic.values()):
  238.                     cls.mercenary_error(1)
  239.                     return
  240.                 print('Iteration will show logs with these gamemodes:')
  241.                 for display in mercenary_dic.values():
  242.                     print(display)
  243.                 mercenary_selection = input("\nTo REMOVE a class: Pick 1 - 9 or leave blank to exit.\n> ")
  244.                 if not mercenary_selection:
  245.                     menu()
  246.                     return
  247.                 if mercenary_selection not in ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
  248.                     cls.mercenary_interface()
  249.                     return
  250.                 else:
  251.                     mercenary_dic[mercenary_selection] = ''
  252.                     cls.mercenary_interface()
  253.    
  254.     def selection(number_filter):
  255.         global start_date_lst_int
  256.         global end_date_lst_int
  257.         global curdate
  258.         global gamemode_dic
  259.         global mercenary_dic
  260.        
  261.         global firstdate
  262.         global gamemode_printed
  263.        
  264.         if number_filter not in ['1', '2', '3', '4']:
  265.             menu()
  266.         if number_filter == '1':
  267.             Daterange.daterangestart()
  268.            
  269.         if number_filter == '2':
  270.             Gamemode.gamemode_interface()
  271.            
  272.         if number_filter == '3':
  273.             Mercenary.mercenary_interface()
  274.            
  275.         if number_filter == '4':
  276.             os.system('cls' if os.name == 'nt' else 'clear')
  277.             print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  278.            
  279.             if start_date_lst_int is not None and end_date_lst_int is not None:
  280.                 print('Date Range: ' + calendar.month_name[start_date_lst_int[-3]] + ' ' + str(start_date_lst_int[-2]) + ', ' + str(start_date_lst_int[-1]) + ' - ' + calendar.month_name[end_date_lst_int[-3]] + ' ' + str(end_date_lst_int[-2]) + ', ' + str(end_date_lst_int[-1]))
  281.                    
  282.             elif curdate is not None:
  283.                 if not firstdate:
  284.                     print('Date Range: ' + calendar.month_name[start_date_lst_int[-3]] + ' ' + str(start_date_lst_int[-2]) + ', ' + str(start_date_lst_int[-1]) + ' - ' + calendar.month_name[int(curdate[0])] + ' ' + str(curdate[1]) + ', ' + str(curdate[2]))
  285.                 else:
  286.                     create_dates()
  287.                     print('Date Range: All')
  288.                    
  289.                    
  290.             elif firstdate and end_date_lst_int is not None:
  291.                 print('Date Range: First Log - ' + calendar.month_name[end_date_lst_int[-3]] + ' ' + str(end_date_lst_int[-2]) + ', ' + str(end_date_lst_int[-1]))
  292.             else:
  293.                 print('Date Range: All')
  294.            
  295.             gamemode_printed = False
  296.             for value in gamemode_dic.values():
  297.                 if value == '':
  298.                     search_gamemodes = "".join(str(value) for value in gamemode_dic.values())
  299.                     gamemode_printed = True
  300.                     print('Gamemodes: ' + print_sorter(search_gamemodes))
  301.                     break
  302.                 else:
  303.                     pass
  304.             if not gamemode_printed:
  305.                 print('Gamemodes: All')
  306.  
  307.             mercenary_printed = False
  308.             for value in mercenary_dic.values():
  309.                 if value == '':
  310.                     search_mercenarys = "".join(str(value) for value in mercenary_dic.values())
  311.                     mercenary_printed = True
  312.                     print('Classes: ' + print_sorter(search_mercenarys))
  313.                     break
  314.                 else:
  315.                     pass
  316.             if not mercenary_printed:
  317.                 print('Classes: All')
  318.            
  319.            
  320.             def ask_confirmed():
  321.                 global confirmed
  322.                 confirmed = input('\nPlease confirm the settings above (y/n)\n> ')
  323.                 if confirmed not in ['y', 'n']:
  324.                     ask_confirmed()
  325.             ask_confirmed()
  326.                
  327.             if confirmed == 'n':
  328.                 create_variables()
  329.                 create_dates()
  330.                 print('\nAll Inputs Reset.')
  331.                 exittomenu()
  332.            
  333.                
  334.     def exittomenu():
  335.         sys.stdout.write('Exiting to Menu in 3')
  336.         sys.stdout.flush()
  337.         time.sleep(1)
  338.         for i in range(2, 0, -1):
  339.             sys.stdout.write('\b')
  340.             sys.stdout.write(str(i))
  341.             sys.stdout.flush()
  342.             time.sleep(1)
  343.         menu()
  344.        
  345.     def menu():
  346.         os.system('cls' if os.name == 'nt' else 'clear')
  347.         print(fg.redder + "\nCreated by: Mimky" + fg.rs)
  348.         print('''Pick a number.
  349. [ 1 ] Specificy Date Range
  350. [ 2 ] Gamemode Seperation
  351. [ 3 ] Class Seperation
  352. [ 4 ] Finish
  353. ''')
  354.         number_filter = input('> ')
  355.         selection(number_filter)
  356.        
  357.     menu()
  358.  
  359. start_time = time.time()
  360. if filter_input == 'y':
  361.     spinner = Spinner('Preparing for Iteration based on Current Settings ')
  362. else:
  363.     spinner = Spinner('Preparing for Iteration ')
  364. spinning = True
  365. def start_spin():
  366.     while spinning:
  367.         spinner.next()
  368.         time.sleep(0.1)
  369.     else:
  370.         sys.exit()
  371. t1 = threading.Thread(target=start_spin)
  372. t1.start()
  373.  
  374. def log_id_finder(seperated_logs):
  375.     global all_log_ids
  376.     all_log_ids = []
  377.     search_term_start = '''            "id": '''
  378.     search_term_end = ''','''
  379.     for i in seperated_logs:
  380.         log_id_search = re.search(search_term_start + '(.*?)' + search_term_end, i)
  381.         all_log_ids.append(log_id_search.group(1))
  382.  
  383.  
  384. logsid_prof = requests.get('''https://logs.tf/api/v1/log?player=''' + SID64 + '&limit=10000').text
  385.  
  386. search1 = re.compile('''        {''' + r'(.*?)' + '''        }''', re.DOTALL)
  387. search2 = search1.findall(logsid_prof)
  388.    
  389. custom_date_search = False
  390.  
  391. if start_date_epoch is not None:
  392.     custom_date_search = True
  393.    
  394.     date_search = re.compile('''"date": ''' + r'(.*?)' + ''',''', re.DOTALL)
  395.     date_lst_str = date_search.findall(logsid_prof)
  396.     date_lst = list(map(int, date_lst_str))
  397.     if start_date_epoch == 'first':
  398.         start_date_epoch = date_lst[-1] - 86400
  399.     date_lst_search = []
  400.    
  401.     for i in date_lst:
  402.         if start_date_epoch <= i <= end_date_epoch:
  403.             date_lst_search.append('''"date": ''' + str(i) + ',')
  404.            
  405.     custom_search1 = []
  406.     for i in search2:
  407.         if any(ele in i for ele in date_lst_search):
  408.             custom_search1.append(i)
  409.    
  410. if gamemode_printed:
  411.     gamemode_search_lst = []
  412.     gamemode_players_search = []
  413.    
  414.     def add_game_search(playcount):
  415.         gamemode_players_search.append('''            "players": ''' + playcount)
  416.        
  417.     for key in gamemode_dic.keys():
  418.         if gamemode_dic[key] != '':
  419.             gamemode_search_lst.append(key)
  420.     for i in gamemode_search_lst:
  421.         if i == '1':
  422.             add_game_search('11')
  423.             add_game_search('12')
  424.             add_game_search('13')
  425.         if i == '2':
  426.             add_game_search('17')
  427.             add_game_search('18')
  428.             add_game_search('19')
  429.         if i == '3':
  430.             add_game_search('13')
  431.             add_game_search('14')
  432.             add_game_search('15')
  433.         if i == '4':
  434.             add_game_search('8')
  435.             add_game_search('9')
  436.         if i == '5':
  437.             add_game_search('4')
  438.            
  439.    
  440.     if custom_date_search:
  441.         custom_search2 = []
  442.         for i in custom_search1:
  443.             if any(ele in i for ele in gamemode_players_search):
  444.                 custom_search2.append(i)
  445.         log_id_finder(custom_search2)
  446.     else:
  447.         custom_search1 = []
  448.         for i in search2:
  449.             if any(ele in i for ele in gamemode_players_search):
  450.                 custom_search1.append(i)
  451.         log_id_finder(custom_search1)
  452.        
  453. elif custom_date_search:
  454.     log_id_finder(custom_search1)
  455.    
  456. else:
  457.     log_id_finder(search2)
  458.    
  459. def epoch_time_converter(total_time, col):
  460.     time = total_time % (24 * 3600)
  461.     hour = total_time // 3600
  462.     total_time %= 3600
  463.     minutes = total_time // 60
  464.     total_time %= 60
  465.     seconds = total_time
  466.     if col is False:
  467.         return(str(int(hour)) + ' hours ' + str(int(minutes)) + ' minutes ' + str(int(seconds)) + ' seconds.')
  468.     else:
  469.         return(fg.yellow + str(int(hour)) + fg.rs + ' hours ' + fg.yellow + str(int(minutes)) + fg.rs + ' minutes ' + fg.yellow + str(int(seconds)) + fg.rs + ' seconds.')
  470.    
  471. eta = len(all_log_ids) * 0.715
  472. print('\n\nEstimated Search Time: ' + epoch_time_converter(eta, False))
  473.  
  474. mercenary_custom = False
  475. search_mercenarys = "".join(str(value) for value in mercenary_dic.values())
  476. search_mercenarys2 = print_sorter(search_mercenarys).split(', ')
  477. custom_class_lst = [x.lower() for x in search_mercenarys2]
  478. for i in custom_class_lst:
  479.     if i == 'heavy':
  480.         custom_class_lst.remove(i)
  481.         custom_class_lst.append('heavyweapons')
  482.        
  483. def start_iteration():
  484.    
  485.     scout_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  486.     soldier_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  487.     pyro_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  488.     demoman_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  489.     heavyweapons_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  490.     engineer_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  491.     medic_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  492.     sniper_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  493.     spy_dict = {"time": [], "kills": [], "deaths": [], "dmg": []}
  494.    
  495.     scout_lst = []
  496.     soldier_lst = []
  497.     pyro_lst = []
  498.     demoman_lst = []
  499.     heavyweapons_lst = []
  500.     engineer_lst = []
  501.     medic_lst = []
  502.     sniper_lst = []
  503.     spy_lst = []
  504.    
  505.     class_lst_search = [scout_lst, soldier_lst, pyro_lst, demoman_lst, heavyweapons_lst, engineer_lst, medic_lst, sniper_lst, spy_lst]
  506.     class_dict_search = [scout_dict, soldier_dict, pyro_dict, demoman_dict, heavyweapons_dict, engineer_dict, medic_dict, sniper_dict, spy_dict]
  507.     cap_lst = []
  508.    
  509.     counter = 0
  510.     x2 = []
  511.     x3 = []
  512.    
  513.     print('\n')
  514.    
  515.     for i in all_log_ids:
  516.         counter += 1
  517.         log_printer = 'https://logs.tf/json/' + i
  518.         print("\nGrabbing logs from: " "{} ({}%)".format(log_printer, round(100*counter/len(all_log_ids), 1)), end = '')
  519.         log_iterator = requests.get(log_printer).text
  520.        
  521.         x1 = re.search(SID3 + '(.*?)' + 'U:1:', log_iterator)
  522.         try:
  523.             x2.append(x1.group(1))
  524.         except AttributeError:
  525.             print(fg.red + ' ERROR: Log appears to be broken / outdated (skipped).' + fg.rs)
  526.             if i == all_log_ids[-1]:
  527.                 time.sleep(1)
  528.                
  529.  
  530.     for i in x2:
  531.         y1 = re.search('''"cpc": ''' + '(.*?)' + ''', "''', i)
  532.         y2 = y1.group(1)
  533.         cap_lst.append(y2)
  534.         y3 = i.split('''"type": "''')
  535.         y3.pop(0)
  536.         for e in y3:
  537.             if any(ele in e for ele in custom_class_lst):
  538.                 x3.append(e)
  539.  
  540.     for i in x3:
  541.         y4 = i.split('''", ''')[0]
  542.         try:
  543.             eval(y4 + '_lst').append(i)
  544.         except NameError:
  545.             pass
  546.        
  547.            
  548.     for i in class_lst_search:
  549.         for e in i:
  550.             w1 = re.search('''"total_time": ''' + '(.*?)' + '''}''', e)
  551.             w2 = re.search('''"kills": ''' + '(.*?)' + ''', "''', e)
  552.             w3 = re.search('''"deaths": ''' + '(.*?)' + ''', "''', e)
  553.             w4 = re.search('''"dmg": ''' + '(.*?)' + ''', "''', e)
  554.             try:
  555.                 z1 = w1.group(1)
  556.                 z2 = w2.group(1)
  557.                 z3 = w3.group(1)
  558.                 z4 = w4.group(1)
  559.             except AttributeError:
  560.                 continue
  561.             class_dict_name1 = [k for k, v in locals().items() if v == i][0]
  562.             class_dict_name2 = class_dict_name1.split('_', 1)
  563.             class_dict = eval(class_dict_name2[0] + '_dict')
  564.            
  565.             class_dict["time"].append(z1)
  566.             class_dict["kills"].append(z2)
  567.             class_dict["deaths"].append(z3)
  568.             class_dict["dmg"].append(z4)
  569.            
  570.  
  571.     os.system('cls' if os.name == 'nt' else 'clear')
  572.     print(fg.redder + "\nCreated by: Mimky\n" + fg.rs)
  573.    
  574.     complete_time = 0
  575.     complete_kills = 0
  576.     complete_deaths = 0
  577.     complete_damage = 0
  578.  
  579.     fg.lightgreen = Style(RgbFg(102,255,102))
  580.     fg.lightred = Style(RgbFg(255,102,102))
  581.     fg.lightpurple = Style(RgbFg(153,51,255))
  582.     fg.lightblue = Style(RgbFg(110,110,255))
  583.     fg.bluerr = Style(RgbFg(80,80,255))
  584.     fg.lightyellow = Style(RgbFg(255,255,51))
  585.    
  586.     class_name_printer = 0
  587.    
  588.     for dict in class_dict_search:
  589.        
  590.         total_time = sum(list(map(int, dict["time"])))
  591.         total_kills = sum(list(map(int, dict["kills"])))
  592.         total_deaths = sum(list(map(int, dict["deaths"])))
  593.         total_damage = sum(list(map(int, dict["dmg"])))
  594.        
  595.         try:
  596.             avg_kills = total_kills / (total_time / 1800)
  597.             avg_deaths = total_deaths / (total_time / 1800)
  598.             total_dpm = total_damage / (total_time / 60)
  599.             total_kd = avg_kills / avg_deaths
  600.         except ZeroDivisionError:
  601.             continue
  602.        
  603.         class_name1 = [k for k, v in locals().items() if v == dict][0]
  604.         class_name2 = class_name1.split('_', 1)
  605.         class_name3 = class_name2[0]
  606.         if class_name3 not in custom_class_lst:
  607.             continue
  608.        
  609.         class_name_printer += 1
  610.         class_name = class_name3.upper()
  611.         if class_name == 'HEAVYWEAPONS':
  612.             class_name = 'HEAVY'
  613.  
  614.         complete_time += total_time
  615.         complete_kills += total_kills
  616.         complete_deaths += total_deaths
  617.         complete_damage += total_damage
  618.  
  619.         print(class_name + ':\n')
  620.         print('\tTotal Kills:  ' + fg.green + str(total_kills) + fg.rs)
  621.         print('\tTotal Deaths: ' + fg.red + str(total_deaths) + fg.rs)
  622.         print('\tTotal Damage: ' + fg.bluerr + str(total_damage) + fg.rs)
  623.  
  624.         print('\n\tAverage Kills (Per 30 Minutes):  ' + fg.lightgreen + str(round(avg_kills, 2)) + fg.rs)
  625.         print('\tAverage Deaths (Per 30 Minutes): ' + fg.lightred + str(round(avg_deaths, 2)) + fg.rs)
  626.        
  627.         print('\n\tTotal DPM: ' + fg.lightblue + str(round(total_dpm, 2)) + fg.rs)
  628.         print('\tTotal K/D: ' + fg.lightpurple + str(round(total_kd, 2)) + fg.rs)
  629.         print('\tTotal Time Played: ' + epoch_time_converter(total_time, True) + '\n\n')
  630.        
  631.     end_time = time.time() - start_time
  632.     total_caps = sum(list(map(int, cap_lst)))
  633.     if class_name_printer > 1:
  634.         try:
  635.             print('\nOverall Stats:\n')
  636.             print('\tCombined Kills:  ' + fg.green + str(complete_kills) + fg.rs)
  637.             print('\tCombined Deaths: ' + fg.red + str(complete_deaths) + fg.rs)
  638.             print('\tCombined Damage: ' + fg.bluerr + str(complete_damage) + fg.rs)
  639.            
  640.             print('\n\tMedian Kills (Per 30 Minutes):  ' + fg.lightgreen + str(round(complete_kills / (complete_time / 1800), 2)) + fg.rs)
  641.             print('\tMedian Deaths (Per 30 Minutes): ' + fg.lightred + str(round(complete_deaths / (complete_time / 1800), 2)) + fg.rs)
  642.        
  643.             print('\n\tCombined DPM: ' + fg.lightblue + str(round(complete_damage / (complete_time / 60), 2)) + fg.rs)
  644.             print('\tCombined K/D: ' + fg.lightpurple + str(round(complete_kills / complete_deaths, 2)) + fg.rs)
  645.             print('\tCombined Time Played: ' + epoch_time_converter(complete_time, True))
  646.             print('\n\tTotal Caps: ' + fg.lightyellow + str(total_caps) + fg.rs + ' in ' + str(len(all_log_ids)) + ' logs.')
  647.             print('\n\nTotal Time Elapsed: ' + epoch_time_converter(end_time, True))
  648.  
  649.         except ZeroDivisionError:
  650.             os.system('cls' if os.name == 'nt' else 'clear')
  651.             print(fg.redder + "\nCreated by: Mimky\n" + fg.rs)
  652.             print('ZeroDivisionError occurred.\nLog list is invalid.')
  653.             print('Total Time Elapsed: ' + epoch_time_converter(end_time, True))
  654.             input('\nPress Enter to Quit...')
  655.             sys.exit()
  656.  
  657.     else:
  658.         print('Total Caps: ' + fg.lightyellow + str(total_caps) + fg.rs + ' in ' + str(len(all_log_ids)) + ' logs.')
  659.         print('\nTotal Time Elapsed: ' + epoch_time_converter(end_time, True))
  660.     input('\n\nPress Enter to Quit...')
  661.    
  662.  
  663.  
  664.        
  665. spinning = False
  666. start_iteration()
RAW Paste Data