GameSentenceMiner 2.14.9__py3-none-any.whl → 2.14.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. GameSentenceMiner/ai/__init__.py +0 -0
  2. GameSentenceMiner/ai/ai_prompting.py +473 -0
  3. GameSentenceMiner/ocr/__init__.py +0 -0
  4. GameSentenceMiner/ocr/gsm_ocr_config.py +174 -0
  5. GameSentenceMiner/ocr/ocrconfig.py +129 -0
  6. GameSentenceMiner/ocr/owocr_area_selector.py +629 -0
  7. GameSentenceMiner/ocr/owocr_helper.py +638 -0
  8. GameSentenceMiner/ocr/ss_picker.py +140 -0
  9. GameSentenceMiner/owocr/owocr/__init__.py +1 -0
  10. GameSentenceMiner/owocr/owocr/__main__.py +9 -0
  11. GameSentenceMiner/owocr/owocr/config.py +148 -0
  12. GameSentenceMiner/owocr/owocr/lens_betterproto.py +1238 -0
  13. GameSentenceMiner/owocr/owocr/ocr.py +1690 -0
  14. GameSentenceMiner/owocr/owocr/run.py +1818 -0
  15. GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py +109 -0
  16. GameSentenceMiner/tools/__init__.py +0 -0
  17. GameSentenceMiner/tools/audio_offset_selector.py +215 -0
  18. GameSentenceMiner/tools/ss_selector.py +135 -0
  19. GameSentenceMiner/tools/window_transparency.py +214 -0
  20. GameSentenceMiner/util/__init__.py +0 -0
  21. GameSentenceMiner/util/communication/__init__.py +22 -0
  22. GameSentenceMiner/util/communication/send.py +7 -0
  23. GameSentenceMiner/util/communication/websocket.py +94 -0
  24. GameSentenceMiner/util/configuration.py +1199 -0
  25. GameSentenceMiner/util/db.py +408 -0
  26. GameSentenceMiner/util/downloader/Untitled_json.py +472 -0
  27. GameSentenceMiner/util/downloader/__init__.py +0 -0
  28. GameSentenceMiner/util/downloader/download_tools.py +194 -0
  29. GameSentenceMiner/util/downloader/oneocr_dl.py +250 -0
  30. GameSentenceMiner/util/electron_config.py +259 -0
  31. GameSentenceMiner/util/ffmpeg.py +571 -0
  32. GameSentenceMiner/util/get_overlay_coords.py +366 -0
  33. GameSentenceMiner/util/gsm_utils.py +323 -0
  34. GameSentenceMiner/util/model.py +206 -0
  35. GameSentenceMiner/util/notification.py +157 -0
  36. GameSentenceMiner/util/text_log.py +214 -0
  37. GameSentenceMiner/util/win10toast/__init__.py +154 -0
  38. GameSentenceMiner/util/win10toast/__main__.py +22 -0
  39. GameSentenceMiner/web/__init__.py +0 -0
  40. GameSentenceMiner/web/service.py +132 -0
  41. GameSentenceMiner/web/static/__init__.py +0 -0
  42. GameSentenceMiner/web/static/apple-touch-icon.png +0 -0
  43. GameSentenceMiner/web/static/favicon-96x96.png +0 -0
  44. GameSentenceMiner/web/static/favicon.ico +0 -0
  45. GameSentenceMiner/web/static/favicon.svg +3 -0
  46. GameSentenceMiner/web/static/site.webmanifest +21 -0
  47. GameSentenceMiner/web/static/style.css +292 -0
  48. GameSentenceMiner/web/static/web-app-manifest-192x192.png +0 -0
  49. GameSentenceMiner/web/static/web-app-manifest-512x512.png +0 -0
  50. GameSentenceMiner/web/templates/__init__.py +0 -0
  51. GameSentenceMiner/web/templates/index.html +50 -0
  52. GameSentenceMiner/web/templates/text_replacements.html +238 -0
  53. GameSentenceMiner/web/templates/utility.html +483 -0
  54. GameSentenceMiner/web/texthooking_page.py +584 -0
  55. GameSentenceMiner/wip/__init___.py +0 -0
  56. {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/METADATA +1 -1
  57. gamesentenceminer-2.14.10.dist-info/RECORD +79 -0
  58. gamesentenceminer-2.14.9.dist-info/RECORD +0 -24
  59. {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/WHEEL +0 -0
  60. {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/entry_points.txt +0 -0
  61. {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/licenses/LICENSE +0 -0
  62. {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,22 @@
1
+ import os.path
2
+ from dataclasses import dataclass, field
3
+ from typing import Dict, Optional, Any
4
+
5
+ from dataclasses_json import dataclass_json, Undefined
6
+ from websocket import WebSocket
7
+
8
+ from GameSentenceMiner.util.configuration import get_app_directory
9
+
10
+ CONFIG_FILE = os.path.join(get_app_directory(), "shared_config.json")
11
+ websocket: WebSocket = None
12
+
13
+ @dataclass_json(undefined=Undefined.RAISE)
14
+ @dataclass
15
+ class Message:
16
+ """
17
+ Represents a message for inter-process communication.
18
+ Mimics the structure of IPC or HTTP calls.
19
+ """
20
+ function: str
21
+ data: Dict[str, Any] = field(default_factory=dict)
22
+ id: Optional[str] = None
@@ -0,0 +1,7 @@
1
+ import json
2
+
3
+ from GameSentenceMiner.util.communication.websocket import websocket, Message
4
+
5
+ async def send_restart_signal():
6
+ if websocket:
7
+ await websocket.send(json.dumps(Message(function="restart").to_json()))
@@ -0,0 +1,94 @@
1
+ import asyncio
2
+ import os.path
3
+
4
+ import websockets
5
+ import json
6
+ from enum import Enum
7
+
8
+ from websocket import WebSocket
9
+
10
+ from GameSentenceMiner.util.communication import Message
11
+ from GameSentenceMiner.util.configuration import get_app_directory, logger
12
+
13
+ CONFIG_FILE = os.path.join(get_app_directory(), "shared_config.json")
14
+ websocket: WebSocket = None
15
+ handle_websocket_message = None
16
+
17
+
18
+ class FunctionName(Enum):
19
+ QUIT = "quit"
20
+ START = "start"
21
+ STOP = "stop"
22
+ QUIT_OBS = "quit_obs"
23
+ START_OBS = "start_obs"
24
+ OPEN_SETTINGS = "open_settings"
25
+ OPEN_TEXTHOOKER = "open_texthooker"
26
+ OPEN_LOG = "open_log"
27
+ TOGGLE_REPLAY_BUFFER = "toggle_replay_buffer"
28
+ RESTART_OBS = "restart_obs"
29
+ EXIT = "exit"
30
+ GET_STATUS = "get_status"
31
+
32
+
33
+ async def do_websocket_connection(port):
34
+ """
35
+ Connects to the WebSocket server running in the Electron app.
36
+ """
37
+ global websocket
38
+
39
+ uri = f"ws://localhost:{port}" # Use the port from Electron
40
+ logger.debug(f"Electron Communication : Connecting to server at {uri}...")
41
+ try:
42
+ async with websockets.connect(uri) as websocket:
43
+ logger.debug(f"Connected to websocket server at {uri}")
44
+
45
+ # Send an initial message
46
+ message = Message(function="on_connect", data={"message": "Hello from Python!"})
47
+ await websocket.send(message.to_json())
48
+ logger.debug(f"> Sent: {message}")
49
+
50
+ # Receive messages from the server
51
+ while True:
52
+ try:
53
+ response = await websocket.recv()
54
+ if response is None:
55
+ break
56
+ logger.debug(f"Electron Communication : < Received: {response}")
57
+ handle_websocket_message(Message.from_json(response))
58
+ await asyncio.sleep(1) # keep the connection alive
59
+ except websockets.ConnectionClosedOK:
60
+ logger.debug("Electron Communication : Connection closed by server")
61
+ break
62
+ except websockets.ConnectionClosedError as e:
63
+ logger.debug(f"Electron Communication : Connection closed with error: {e}")
64
+ break
65
+ except ConnectionRefusedError:
66
+ logger.debug(f"Electron Communication : Error: Could not connect to server at {uri}. Electron App not running..")
67
+ except Exception as e:
68
+ logger.debug(f"Electron Communication : An error occurred: {e}")
69
+
70
+ def connect_websocket():
71
+ """
72
+ Main function to run the WebSocket client.
73
+ """
74
+ # Load the port from the same config.json the Electron app uses
75
+ try:
76
+ with open(CONFIG_FILE, "r") as f:
77
+ config = json.load(f)
78
+ port = config["port"]
79
+ except FileNotFoundError:
80
+ print("Error: shared_config.json not found. Using default port 8766. Ensure Electron app creates this file.")
81
+ port = 8766 # Default port, same as in Electron
82
+ except json.JSONDecodeError:
83
+ print("Error: shared_config.json was not valid JSON. Using default port 8765.")
84
+ port = 8766
85
+
86
+ asyncio.run(do_websocket_connection(port))
87
+
88
+ def register_websocket_message_handler(handler):
89
+ global handle_websocket_message
90
+ handle_websocket_message = handler
91
+
92
+
93
+ if __name__ == "__main__":
94
+ connect_websocket()