GameSentenceMiner 2.5.6__py3-none-any.whl → 2.5.8__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.
@@ -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.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.communication.websocket import websocket, Message
4
+
5
+ def send_restart_signal():
6
+ if websocket and websocket.connected:
7
+ websocket.send(json.dumps(Message(function="restart").to_json()))
@@ -0,0 +1,77 @@
1
+ import asyncio
2
+ import os.path
3
+
4
+ import websockets
5
+ import json
6
+
7
+ from websocket import WebSocket
8
+
9
+ from GameSentenceMiner.communication import Message
10
+ from GameSentenceMiner.configuration import get_app_directory, logger
11
+
12
+ CONFIG_FILE = os.path.join(get_app_directory(), "shared_config.json")
13
+ websocket: WebSocket = None
14
+ handle_websocket_message = None
15
+
16
+ async def do_websocket_connection(port):
17
+ """
18
+ Connects to the WebSocket server running in the Electron app.
19
+ """
20
+ global websocket
21
+
22
+ uri = f"ws://localhost:{port}" # Use the port from Electron
23
+ logger.debug(f"Electron Communication : Connecting to server at {uri}...")
24
+ try:
25
+ async with websockets.connect(uri) as websocket:
26
+ logger.debug(f"Connected to websocket server at {uri}")
27
+
28
+ # Send an initial message
29
+ message = Message(function="on_connect", data={"message": "Hello from Python!"})
30
+ await websocket.send(message.to_json())
31
+ logger.debug(f"> Sent: {message}")
32
+
33
+ # Receive messages from the server
34
+ while True:
35
+ try:
36
+ response = await websocket.recv()
37
+ if response is None:
38
+ break
39
+ logger.debug(f"Electron Communication : < Received: {response}")
40
+ handle_websocket_message(Message.from_json(response))
41
+ await asyncio.sleep(1) # keep the connection alive
42
+ except websockets.ConnectionClosedOK:
43
+ logger.debug("Electron Communication : Connection closed by server")
44
+ break
45
+ except websockets.ConnectionClosedError as e:
46
+ logger.debug(f"Electron Communication : Connection closed with error: {e}")
47
+ break
48
+ except ConnectionRefusedError:
49
+ logger.debug(f"Electron Communication : Error: Could not connect to server at {uri}. Electron App not running..")
50
+ except Exception as e:
51
+ logger.debug(f"Electron Communication : An error occurred: {e}")
52
+
53
+ def connect_websocket():
54
+ """
55
+ Main function to run the WebSocket client.
56
+ """
57
+ # Load the port from the same config.json the Electron app uses
58
+ try:
59
+ with open(CONFIG_FILE, "r") as f:
60
+ config = json.load(f)
61
+ port = config["port"]
62
+ except FileNotFoundError:
63
+ print("Error: shared_config.json not found. Using default port 8766. Ensure Electron app creates this file.")
64
+ port = 8766 # Default port, same as in Electron
65
+ except json.JSONDecodeError:
66
+ print("Error: shared_config.json was not valid JSON. Using default port 8765.")
67
+ port = 8766
68
+
69
+ asyncio.run(do_websocket_connection(port))
70
+
71
+ def register_websocket_message_handler(handler):
72
+ global handle_websocket_message
73
+ handle_websocket_message = handler
74
+
75
+
76
+ if __name__ == "__main__":
77
+ connect_websocket()
GameSentenceMiner/gsm.py CHANGED
@@ -222,14 +222,18 @@ def play_video_in_external(line, filepath):
222
222
  p.wait()
223
223
  os.remove(fp)
224
224
 
225
- command = [get_config().advanced.video_player_path, os.path.normpath(filepath)]
225
+ command = [get_config().advanced.video_player_path]
226
226
 
227
227
  start, _, _ = get_video_timings(filepath, line)
228
228
 
229
229
  print(start)
230
230
 
231
- if start:
232
- command.extend(["--start-time", convert_to_vlc_seconds(start)])
231
+ if "vlc" in get_config().advanced.video_player_path:
232
+ command.append("--start-time")
233
+ else:
234
+ command.append("--start")
235
+
236
+ command.extend([convert_to_vlc_seconds(start), os.path.normpath(filepath)])
233
237
 
234
238
  try:
235
239
  proc = subprocess.Popen(command)
@@ -319,7 +323,7 @@ def open_multimine():
319
323
  get_utility_window().show()
320
324
 
321
325
  def play_most_recent_audio():
322
- if get_config().advanced.audio_player_path or get_config().advanced.video_player_path and len(gametext.line_history) > 0:
326
+ if get_config().advanced.audio_player_path or get_config().advanced.video_player_path and len(gametext.line_history.values) > 0:
323
327
  get_utility_window().line_for_audio = gametext.line_history.values[-1]
324
328
  obs.save_replay_buffer()
325
329
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.5.6
3
+ Version: 2.5.8
4
4
  Summary: A tool for mining sentences from games. Update: Multi-Line Mining! Fixed!
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -4,13 +4,16 @@ GameSentenceMiner/config_gui.py,sha256=cLKVliB0X61WNduNisOmaEtqSr1mvTO6ZAiv-t2jW
4
4
  GameSentenceMiner/configuration.py,sha256=-b1wW6EkkOFwF1No1uZLD2nPUV5gfBIzG5a8_ykqyUI,16691
5
5
  GameSentenceMiner/ffmpeg.py,sha256=Bvkk0TMHtoQkpEYQls48CbC4TB0-FzrnqQhRNg36hVk,11831
6
6
  GameSentenceMiner/gametext.py,sha256=LORVdE2WEo1CDI8gonc7qxrhbS4KFKXFQVKjhlkpLbc,7368
7
- GameSentenceMiner/gsm.py,sha256=UeGSoFWV1lq3YS0lcDL4zXmvOEEMvSjeS1KKQpnG3co,24169
7
+ GameSentenceMiner/gsm.py,sha256=H12yXMfeIQk_tTEi---tQmyMacI35HJaQBuviXpoH94,24283
8
8
  GameSentenceMiner/model.py,sha256=bZm-2vkIw4gQCGLB02eDoTtO1Ymb_dnHk0VDJDFO3y8,5228
9
9
  GameSentenceMiner/notification.py,sha256=2d8_8DUxImeC1zY-V4c_PZw1zbvvGZ6KiAnPaSmH9G0,2592
10
10
  GameSentenceMiner/obs.py,sha256=N7XoPSzLk9rHi4sgsG_LS2dN06MrqwN2mpSHfjONTjE,7368
11
11
  GameSentenceMiner/package.py,sha256=YlS6QRMuVlm6mdXx0rlXv9_3erTGS21jaP3PNNWfAH0,1250
12
12
  GameSentenceMiner/util.py,sha256=tkaoU1bj8iPMTNwUCWUzFLAnT44Ot92D1tYwQMEnARw,7336
13
13
  GameSentenceMiner/utility_gui.py,sha256=aVdI9zVXADS53g7QtTgmkVK1LumBsXF4Lou3qJzgHN8,7487
14
+ GameSentenceMiner/communication/__init__.py,sha256=_jGn9PJxtOAOPtJ2rI-Qu9hEHVZVpIvWlxKvqk91_zI,638
15
+ GameSentenceMiner/communication/send.py,sha256=oOJdCS6-LNX90amkRn5FL2xqx6THGm56zHR2ntVIFTE,229
16
+ GameSentenceMiner/communication/websocket.py,sha256=vrZ9KwRUyZOepjayJkxZZTsNIbHGcDLgDRO9dNDwizM,2914
14
17
  GameSentenceMiner/downloader/Untitled_json.py,sha256=RUUl2bbbCpUDUUS0fP0tdvf5FngZ7ILdA_J5TFYAXUQ,15272
15
18
  GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
19
  GameSentenceMiner/downloader/download_tools.py,sha256=mI1u_FGBmBqDIpCH3jOv8DOoZ3obgP5pIf9o9SVfX2Q,8131
@@ -18,9 +21,9 @@ GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
18
21
  GameSentenceMiner/vad/silero_trim.py,sha256=-thDIZLuTLra3YBj7WR16Z6JeDgSpge2YuahprBvD8I,1585
19
22
  GameSentenceMiner/vad/vosk_helper.py,sha256=BI_mg_qyrjNbuEJjXSUDoV0FWEtQtEOAPmrrNixnZ_8,5974
20
23
  GameSentenceMiner/vad/whisper_helper.py,sha256=OF4J8TPPoKPJR1uFwrWAZ2Q7v0HJkVvNGmF8l1tACX0,3447
21
- gamesentenceminer-2.5.6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
22
- gamesentenceminer-2.5.6.dist-info/METADATA,sha256=7mOtW_I06CEVBOLuzCqUvR9h7h_RwrS3OBJoIwsUOqg,5435
23
- gamesentenceminer-2.5.6.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
24
- gamesentenceminer-2.5.6.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
25
- gamesentenceminer-2.5.6.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
26
- gamesentenceminer-2.5.6.dist-info/RECORD,,
24
+ gamesentenceminer-2.5.8.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
25
+ gamesentenceminer-2.5.8.dist-info/METADATA,sha256=wz8fYy9k_SurmsPaB2yUC8wVJD8tZuYhh-0ntKxDICA,5435
26
+ gamesentenceminer-2.5.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
27
+ gamesentenceminer-2.5.8.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
28
+ gamesentenceminer-2.5.8.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
29
+ gamesentenceminer-2.5.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5