diff --git a/assets/build/icon/128x128.png b/assets/build/icon/128x128.png new file mode 100644 index 0000000..463e9cf Binary files /dev/null and b/assets/build/icon/128x128.png differ diff --git a/assets/build/icon/16x16.png b/assets/build/icon/16x16.png new file mode 100644 index 0000000..cc6efb7 Binary files /dev/null and b/assets/build/icon/16x16.png differ diff --git a/assets/build/icon/256x256.png b/assets/build/icon/256x256.png new file mode 100644 index 0000000..dfd0665 Binary files /dev/null and b/assets/build/icon/256x256.png differ diff --git a/assets/build/icon/32x32.png b/assets/build/icon/32x32.png new file mode 100644 index 0000000..da2794a Binary files /dev/null and b/assets/build/icon/32x32.png differ diff --git a/assets/build/icon/48x48.png b/assets/build/icon/48x48.png new file mode 100644 index 0000000..47f6e89 Binary files /dev/null and b/assets/build/icon/48x48.png differ diff --git a/assets/build/icon/512x512.png b/assets/build/icon/512x512.png new file mode 100644 index 0000000..68a0732 Binary files /dev/null and b/assets/build/icon/512x512.png differ diff --git a/assets/build/icon/64x64.png b/assets/build/icon/64x64.png new file mode 100644 index 0000000..e6517c9 Binary files /dev/null and b/assets/build/icon/64x64.png differ diff --git a/assets/build/icon/icon.ico b/assets/build/icon/icon.ico new file mode 100644 index 0000000..156737a Binary files /dev/null and b/assets/build/icon/icon.ico differ diff --git a/bin/get_cod_stats.exe b/bin/get_cod_stats.exe new file mode 100644 index 0000000..d5e893a Binary files /dev/null and b/bin/get_cod_stats.exe differ diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..bec56ca --- /dev/null +++ b/build.bat @@ -0,0 +1,10 @@ +@echo off + +cd /d %~dp0 :: Change directory to the location of this batch file +call venv\Scripts\activate :: Activate the virtual environment +pyinstaller --noconfirm --onefile --console --icon "assets\build\icon\icon.ico" get_cod_stats.py --distpath="bin" -n "get_cod_stats" + +rmdir /s /q build +del /q "get_cod_stats.spec" + +pause diff --git a/deps/altgraph-0.17.4-py2.py3-none-any.whl b/deps/altgraph-0.17.4-py2.py3-none-any.whl new file mode 100644 index 0000000..dbddb0c Binary files /dev/null and b/deps/altgraph-0.17.4-py2.py3-none-any.whl differ diff --git a/deps/importlib_metadata-6.8.0-py3-none-any.whl b/deps/importlib_metadata-6.8.0-py3-none-any.whl new file mode 100644 index 0000000..c3b0b51 Binary files /dev/null and b/deps/importlib_metadata-6.8.0-py3-none-any.whl differ diff --git a/deps/packaging-23.2-py3-none-any.whl b/deps/packaging-23.2-py3-none-any.whl new file mode 100644 index 0000000..bc7b6ab Binary files /dev/null and b/deps/packaging-23.2-py3-none-any.whl differ diff --git a/deps/pefile-2023.2.7-py3-none-any.whl b/deps/pefile-2023.2.7-py3-none-any.whl new file mode 100644 index 0000000..fc394f4 Binary files /dev/null and b/deps/pefile-2023.2.7-py3-none-any.whl differ diff --git a/deps/pip-23.2.1-py3-none-any.whl b/deps/pip-23.2.1-py3-none-any.whl new file mode 100644 index 0000000..ba28ef0 Binary files /dev/null and b/deps/pip-23.2.1-py3-none-any.whl differ diff --git a/deps/pyinstaller-6.0.0-py3-none-win_amd64.whl b/deps/pyinstaller-6.0.0-py3-none-win_amd64.whl new file mode 100644 index 0000000..cc4da31 Binary files /dev/null and b/deps/pyinstaller-6.0.0-py3-none-win_amd64.whl differ diff --git a/deps/pyinstaller_hooks_contrib-2023.9-py2.py3-none-any.whl b/deps/pyinstaller_hooks_contrib-2023.9-py2.py3-none-any.whl new file mode 100644 index 0000000..6e6b6f1 Binary files /dev/null and b/deps/pyinstaller_hooks_contrib-2023.9-py2.py3-none-any.whl differ diff --git a/deps/pywin32_ctypes-0.2.2-py3-none-any.whl b/deps/pywin32_ctypes-0.2.2-py3-none-any.whl new file mode 100644 index 0000000..89fcea9 Binary files /dev/null and b/deps/pywin32_ctypes-0.2.2-py3-none-any.whl differ diff --git a/deps/zipp-3.17.0-py3-none-any.whl b/deps/zipp-3.17.0-py3-none-any.whl new file mode 100644 index 0000000..ead23a5 Binary files /dev/null and b/deps/zipp-3.17.0-py3-none-any.whl differ diff --git a/get_cod_stats.py b/get_cod_stats.py index f776bf2..6abb080 100644 --- a/get_cod_stats.py +++ b/get_cod_stats.py @@ -2,6 +2,11 @@ import json import os import argparse from cod_api import API, platforms +import asyncio + +# Prevent Async error from showing +if os.name == 'nt': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) replacements = { # Gamemodes @@ -247,7 +252,12 @@ replacements = { api = API() COOKIE_FILE = 'cookie.txt' -def get_and_save_data(): +def get_and_save_data(player_name=None): + # Create the stats directory if it doesn't exist + DIR_NAME = 'stats' + if not os.path.exists(DIR_NAME): + os.makedirs(DIR_NAME) + # Check if cookie file exists if os.path.exists(COOKIE_FILE): with open(COOKIE_FILE, 'r') as f: @@ -257,8 +267,9 @@ def get_and_save_data(): with open(COOKIE_FILE, 'w') as f: f.write(api_key) - # Get player name from user - player_name = input("Please enter the player's username (with #1234567): ") + # If player_name is not provided via command line, get it from user input + if not player_name: + player_name = input("Please enter the player's username (with #1234567): ") # Login with sso token api.login(api_key) @@ -270,16 +281,16 @@ def get_and_save_data(): map_list = api.ModernWarfare.mapList(platforms.Activision) identities = api.Me.loggedInIdentities() - # Save results to a JSON file - with open('stats.json', 'w') as json_file: + # Save results to a JSON file inside the stats directory + with open(os.path.join(DIR_NAME, 'stats.json'), 'w') as json_file: json.dump(player_stats, json_file, indent=4) - with open('match_info.json', 'w') as json_file: + with open(os.path.join(DIR_NAME, 'match_info.json'), 'w') as json_file: json.dump(match_info, json_file, indent=4) - with open('season_loot.json', 'w') as json_file: + with open(os.path.join(DIR_NAME, 'season_loot.json'), 'w') as json_file: json.dump(season_loot, json_file, indent=4) - with open('map_list.json', 'w') as json_file: + with open(os.path.join(DIR_NAME, 'map_list.json'), 'w') as json_file: json.dump(map_list, json_file, indent=4) - with open('identities.json', 'w') as json_file: + with open(os.path.join(DIR_NAME, 'identities.json'), 'w') as json_file: json.dump(identities, json_file, indent=4) def recursive_key_replace(obj, replacements): @@ -354,6 +365,7 @@ def main(): # Add arguments for your commands parser.add_argument("--replace-data", action="store_true", help="Beautify the data in stats.json") parser.add_argument("--replace-match-data", action="store_true", help="Beautify the match data in match_info.json") + parser.add_argument("--player-name", type=str, help="Player's username (with #1234567)") args = parser.parse_args() @@ -362,7 +374,7 @@ def main(): elif args.replace_match_data: beautify_match_data() else: - get_and_save_data() + get_and_save_data(args.player_name) if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/setup.py b/setup.py index 3186655..59bc02f 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def create_venv(): f.write("venv\\Scripts\\activate") def upgrade_pip(): - subprocess.check_call([os.path.join('venv', 'Scripts', 'python'), '-m', 'pip', 'install', '--upgrade', 'pip']) + subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'pip']) def install_wheel(): subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'wheel']) @@ -23,7 +23,11 @@ def install_wheel(): def install_requirements_in_venv(): # Use the full path to the wheel file wheel_path = os.path.join('src', 'cod_api-2.0.1-py3-none-any.whl') - subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', wheel_path]) + subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', wheel_path]) + +def install_build_dependencies(): + subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'install', '--no-index', '--find-links=deps', 'pyinstaller']) + subprocess.check_call([os.path.join('venv', 'Scripts', 'pip'), 'uninstall', 'enum34', '-y']) if __name__ == "__main__": if not deps_exists(): @@ -38,4 +42,6 @@ if __name__ == "__main__": install_wheel() print("Installing packages in the virtual environment...") install_requirements_in_venv() # Call the function to install the requirements + print("Installing build dependencies...") + install_build_dependencies() print("Setup complete.") \ No newline at end of file