GameSentenceMiner 2.7.16__py3-none-any.whl → 2.8.0__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 (35) hide show
  1. GameSentenceMiner/anki.py +7 -8
  2. GameSentenceMiner/config_gui.py +19 -3
  3. GameSentenceMiner/configuration.py +8 -1
  4. GameSentenceMiner/ffmpeg.py +1 -3
  5. GameSentenceMiner/gametext.py +16 -155
  6. GameSentenceMiner/gsm.py +28 -29
  7. GameSentenceMiner/obs.py +0 -3
  8. GameSentenceMiner/ocr/ocrconfig.py +0 -1
  9. GameSentenceMiner/ocr/oneocr_dl.py +243 -0
  10. GameSentenceMiner/ocr/owocr_area_selector.py +0 -1
  11. GameSentenceMiner/ocr/owocr_helper.py +25 -26
  12. GameSentenceMiner/owocr/owocr/run.py +1 -1
  13. GameSentenceMiner/text_log.py +186 -0
  14. GameSentenceMiner/util.py +52 -3
  15. GameSentenceMiner/web/__init__.py +0 -0
  16. GameSentenceMiner/web/static/__init__.py +0 -0
  17. GameSentenceMiner/web/static/apple-touch-icon.png +0 -0
  18. GameSentenceMiner/web/static/favicon-96x96.png +0 -0
  19. GameSentenceMiner/web/static/favicon.ico +0 -0
  20. GameSentenceMiner/web/static/favicon.svg +3 -0
  21. GameSentenceMiner/web/static/site.webmanifest +21 -0
  22. GameSentenceMiner/web/static/style.css +292 -0
  23. GameSentenceMiner/web/static/text_replacements.html +238 -0
  24. GameSentenceMiner/web/static/utility.html +313 -0
  25. GameSentenceMiner/web/static/web-app-manifest-192x192.png +0 -0
  26. GameSentenceMiner/web/static/web-app-manifest-512x512.png +0 -0
  27. GameSentenceMiner/web/texthooking_page.py +234 -0
  28. {gamesentenceminer-2.7.16.dist-info → gamesentenceminer-2.8.0.dist-info}/METADATA +2 -1
  29. gamesentenceminer-2.8.0.dist-info/RECORD +58 -0
  30. {gamesentenceminer-2.7.16.dist-info → gamesentenceminer-2.8.0.dist-info}/WHEEL +1 -1
  31. GameSentenceMiner/utility_gui.py +0 -204
  32. gamesentenceminer-2.7.16.dist-info/RECORD +0 -44
  33. {gamesentenceminer-2.7.16.dist-info → gamesentenceminer-2.8.0.dist-info}/entry_points.txt +0 -0
  34. {gamesentenceminer-2.7.16.dist-info → gamesentenceminer-2.8.0.dist-info}/licenses/LICENSE +0 -0
  35. {gamesentenceminer-2.7.16.dist-info → gamesentenceminer-2.8.0.dist-info}/top_level.txt +0 -0
GameSentenceMiner/anki.py CHANGED
@@ -7,16 +7,15 @@ import urllib.request
7
7
  from datetime import datetime, timedelta
8
8
  from requests import post
9
9
 
10
- from GameSentenceMiner import obs, util, notification, ffmpeg, gametext
10
+ from GameSentenceMiner import obs, util, notification, ffmpeg
11
11
  from GameSentenceMiner.ai.gemini import translate_with_context
12
12
  from GameSentenceMiner.configuration import *
13
13
  from GameSentenceMiner.configuration import get_config
14
- from GameSentenceMiner.gametext import get_text_event, get_all_lines
15
14
  from GameSentenceMiner.model import AnkiCard
16
- from GameSentenceMiner.utility_gui import get_utility_window
15
+ from GameSentenceMiner.text_log import get_all_lines, get_text_event, get_mined_line
17
16
  from GameSentenceMiner.obs import get_current_game
18
17
  from GameSentenceMiner.util import remove_html_and_cloze_tags, combine_dialogue
19
-
18
+ from GameSentenceMiner.web import texthooking_page
20
19
 
21
20
  audio_in_anki = None
22
21
  screenshot_in_anki = None
@@ -171,7 +170,7 @@ def get_initial_card_info(last_note: AnkiCard, selected_lines):
171
170
  last_note.get_field(get_config().anki.previous_sentence_field):
172
171
  logger.debug(
173
172
  f"Adding Previous Sentence: {get_config().anki.previous_sentence_field and game_line.prev.text and not last_note.get_field(get_config().anki.previous_sentence_field)}")
174
- if selected_lines:
173
+ if selected_lines and selected_lines[0].prev:
175
174
  note['fields'][get_config().anki.previous_sentence_field] = selected_lines[0].prev.text
176
175
  else:
177
176
  note['fields'][get_config().anki.previous_sentence_field] = game_line.prev.text
@@ -277,10 +276,10 @@ def update_new_card():
277
276
  if get_config().obs.get_game_from_scene:
278
277
  obs.update_current_game()
279
278
  if use_prev_audio:
280
- lines = get_utility_window().get_selected_lines()
279
+ lines = texthooking_page.get_selected_lines()
281
280
  with util.lock:
282
- update_anki_card(last_card, note=get_initial_card_info(last_card, lines), game_line=gametext.get_mined_line(last_card, lines), reuse_audio=True)
283
- get_utility_window().reset_checkboxes()
281
+ update_anki_card(last_card, note=get_initial_card_info(last_card, lines), game_line=get_mined_line(last_card, lines), reuse_audio=True)
282
+ texthooking_page.reset_checked_lines()
284
283
  else:
285
284
  logger.info("New card(s) detected! Added to Processing Queue!")
286
285
  card_queue.append(last_card)
@@ -110,7 +110,8 @@ class ConfigApp:
110
110
  websocket_uri=self.websocket_uri.get(),
111
111
  open_config_on_startup=self.open_config_on_startup.get(),
112
112
  open_multimine_on_startup=self.open_multimine_on_startup.get(),
113
- texthook_replacement_regex=self.texthook_replacement_regex.get()
113
+ texthook_replacement_regex=self.texthook_replacement_regex.get(),
114
+ use_both_clipboard_and_websocket=self.use_both_clipboard_and_websocket.get()
114
115
  ),
115
116
  paths=Paths(
116
117
  folder_to_watch=self.folder_to_watch.get(),
@@ -308,6 +309,13 @@ class ConfigApp:
308
309
  self.add_label_and_increment_row(general_frame, "Enable to allow GSM to see clipboard for text and line timing.",
309
310
  row=self.current_row, column=2)
310
311
 
312
+ ttk.Label(general_frame, text="Allow Both:").grid(row=self.current_row, column=0, sticky='W')
313
+ self.use_both_clipboard_and_websocket = tk.BooleanVar(value=self.settings.general.use_both_clipboard_and_websocket)
314
+ ttk.Checkbutton(general_frame, variable=self.use_both_clipboard_and_websocket).grid(row=self.current_row, column=1,
315
+ sticky='W')
316
+ self.add_label_and_increment_row(general_frame, "Enable to allow GSM to accept both clipboard and websocket input at the same time.",
317
+ row=self.current_row, column=2)
318
+
311
319
  ttk.Label(general_frame, text="Websocket URI:").grid(row=self.current_row, column=0, sticky='W')
312
320
  self.websocket_uri = ttk.Entry(general_frame)
313
321
  self.websocket_uri.insert(0, self.settings.general.websocket_uri)
@@ -329,13 +337,21 @@ class ConfigApp:
329
337
  self.add_label_and_increment_row(general_frame, "Whether to open config when the script starts.",
330
338
  row=self.current_row, column=2)
331
339
 
332
- ttk.Label(general_frame, text="Open Multimine on Startup:").grid(row=self.current_row, column=0, sticky='W')
340
+ ttk.Label(general_frame, text="Open GSM Texthooker on Startup:").grid(row=self.current_row, column=0, sticky='W')
333
341
  self.open_multimine_on_startup = tk.BooleanVar(value=self.settings.general.open_multimine_on_startup)
334
342
  ttk.Checkbutton(general_frame, variable=self.open_multimine_on_startup).grid(row=self.current_row, column=1,
335
343
  sticky='W')
336
- self.add_label_and_increment_row(general_frame, "Whether to open multimining window when the script starts.",
344
+ self.add_label_and_increment_row(general_frame, "Whether to open Texthooking page when the script starts.",
337
345
  row=self.current_row, column=2)
338
346
 
347
+ ttk.Label(general_frame, text="GSM Texthooker Port:").grid(row=self.current_row, column=0, sticky='W')
348
+ self.texthooker_port = ttk.Entry(general_frame)
349
+ self.texthooker_port.insert(0, str(self.settings.general.texthooker_port))
350
+ self.texthooker_port.grid(row=self.current_row, column=1)
351
+ self.add_label_and_increment_row(general_frame, "Port for the Texthooker to run on. Only change if you know what you are doing", row=self.current_row,
352
+ column=2)
353
+
354
+
339
355
  ttk.Label(general_frame, text="Current Version:").grid(row=self.current_row, column=0, sticky='W')
340
356
  self.current_version = ttk.Label(general_frame, text=get_current_version())
341
357
  self.current_version.grid(row=self.current_row, column=1)
@@ -2,6 +2,7 @@ import json
2
2
  import logging
3
3
  import os
4
4
  import shutil
5
+ import socket
5
6
  from dataclasses import dataclass, field
6
7
  from logging.handlers import RotatingFileHandler
7
8
  from os.path import expanduser
@@ -36,16 +37,17 @@ DEFAULT_CONFIG = 'Default'
36
37
 
37
38
  current_game = ''
38
39
 
39
-
40
40
  @dataclass_json
41
41
  @dataclass
42
42
  class General:
43
43
  use_websocket: bool = True
44
44
  use_clipboard: bool = True
45
+ use_both_clipboard_and_websocket: bool = False
45
46
  websocket_uri: str = 'localhost:6677'
46
47
  open_config_on_startup: bool = False
47
48
  open_multimine_on_startup: bool = False
48
49
  texthook_replacement_regex: str = ""
50
+ texthooker_port: int = 55000
49
51
 
50
52
 
51
53
  @dataclass_json
@@ -344,11 +346,16 @@ class Config:
344
346
  self.sync_shared_field(config.general, profile.general, "open_config_on_startup")
345
347
  self.sync_shared_field(config.general, profile.general, "open_multimine_on_startup")
346
348
  self.sync_shared_field(config.general, profile.general, "websocket_uri")
349
+ self.sync_shared_field(config.general, profile.general, "texthooker_port")
347
350
  self.sync_shared_field(config.audio, profile.audio, "external_tool")
348
351
  self.sync_shared_field(config.audio, profile.audio, "anki_media_collection")
349
352
  self.sync_shared_field(config, profile, "advanced")
350
353
  self.sync_shared_field(config, profile, "paths")
351
354
  self.sync_shared_field(config, profile, "obs")
355
+ self.sync_shared_field(config.ai, profile.ai, "anki_field")
356
+ self.sync_shared_field(config.ai, profile.ai, "provider")
357
+ self.sync_shared_field(config.ai, profile.ai, "api_key")
358
+
352
359
 
353
360
  return self
354
361
 
@@ -1,11 +1,9 @@
1
- import subprocess
2
1
  import tempfile
3
- import time
4
2
 
5
3
  from GameSentenceMiner import obs, util, configuration
6
4
  from GameSentenceMiner.configuration import *
5
+ from GameSentenceMiner.text_log import initial_time
7
6
  from GameSentenceMiner.util import *
8
- from GameSentenceMiner.gametext import initial_time
9
7
 
10
8
 
11
9
  def get_ffmpeg_path():
@@ -1,24 +1,19 @@
1
1
  import asyncio
2
- import difflib
3
2
  import re
4
3
  import threading
5
4
  import time
6
- from datetime import datetime, timedelta
7
5
 
8
6
  import pyperclip
9
7
  import websockets
10
8
  from websockets import InvalidStatus
11
9
 
12
10
  from GameSentenceMiner import util
13
- from GameSentenceMiner.model import AnkiCard
14
11
  from GameSentenceMiner.configuration import *
15
- from GameSentenceMiner.configuration import get_config, logger
16
- from GameSentenceMiner.util import remove_html_and_cloze_tags
17
- from difflib import SequenceMatcher
12
+ from GameSentenceMiner.text_log import *
13
+ from GameSentenceMiner.util import do_text_replacements, TEXT_REPLACEMENTS_FILE
18
14
 
19
- from GameSentenceMiner.utility_gui import get_utility_window
15
+ from GameSentenceMiner.web.texthooking_page import add_event_to_texthooker
20
16
 
21
- initial_time = datetime.now()
22
17
  current_line = ''
23
18
  current_line_after_regex = ''
24
19
  current_line_time = datetime.now()
@@ -26,72 +21,9 @@ current_line_time = datetime.now()
26
21
  reconnecting = False
27
22
  websocket_connected = False
28
23
 
29
- @dataclass
30
- class GameLine:
31
- text: str
32
- time: datetime
33
- prev: 'GameLine'
34
- next: 'GameLine'
35
- index: int = 0
36
-
37
- def get_previous_time(self):
38
- if self.prev:
39
- return self.prev.time
40
- return initial_time
41
-
42
- def get_next_time(self):
43
- if self.next:
44
- return self.next.time
45
- return 0
46
-
47
- def __str__(self):
48
- return str({"text": self.text, "time": self.time})
49
-
50
- @dataclass
51
- class GameText:
52
- values: list[GameLine]
53
- game_line_index = 0
54
-
55
- def __init__(self):
56
- self.values = []
57
-
58
- def __getitem__(self, key):
59
- return self.values[key]
60
-
61
- def get_time(self, line_text: str, occurrence: int = -1) -> datetime:
62
- matches = [line for line in self.values if line.text == line_text]
63
- if matches:
64
- return matches[occurrence].time # Default to latest
65
- return initial_time
66
-
67
- def get_event(self, line_text: str, occurrence: int = -1) -> GameLine | None:
68
- matches = [line for line in self.values if line.text == line_text]
69
- if matches:
70
- return matches[occurrence]
71
- return None
72
-
73
- def add_line(self, line_text, line_time=None):
74
- if not line_text:
75
- return
76
- new_line = GameLine(line_text, line_time if line_time else datetime.now(), self.values[-1] if self.values else None, None, self.game_line_index)
77
- logger.debug(f"Adding line: {new_line}")
78
- self.game_line_index += 1
79
- if self.values:
80
- self.values[-1].next = new_line
81
- self.values.append(new_line)
82
- # self.remove_old_events(datetime.now() - timedelta(minutes=10))
83
-
84
- def has_line(self, line_text) -> bool:
85
- for game_line in self.values:
86
- if game_line.text == line_text:
87
- return True
88
- return False
89
-
90
24
  # def remove_old_events(self, cutoff_time: datetime):
91
25
  # self.values = [line for line in self.values if line.time >= cutoff_time]
92
26
 
93
- line_history = GameText()
94
-
95
27
  class ClipboardMonitor(threading.Thread):
96
28
 
97
29
  def __init__(self):
@@ -99,14 +31,14 @@ class ClipboardMonitor(threading.Thread):
99
31
  self.daemon = True
100
32
 
101
33
  def run(self):
102
- global current_line_time, current_line, line_history
34
+ global current_line_time, current_line
103
35
 
104
36
  # Initial clipboard content
105
37
  current_line = pyperclip.paste()
106
38
 
107
39
  skip_next_clipboard = False
108
40
  while True:
109
- if websocket_connected:
41
+ if not get_config().general.use_both_clipboard_and_websocket and websocket_connected:
110
42
  time.sleep(1)
111
43
  skip_next_clipboard = True
112
44
  continue
@@ -120,7 +52,7 @@ class ClipboardMonitor(threading.Thread):
120
52
 
121
53
 
122
54
  async def listen_websocket():
123
- global current_line, current_line_time, line_history, reconnecting, websocket_connected
55
+ global current_line, current_line_time, reconnecting, websocket_connected
124
56
  try_other = False
125
57
  websocket_url = f'ws://{get_config().general.websocket_uri}/gsm'
126
58
  while True:
@@ -130,7 +62,7 @@ async def listen_websocket():
130
62
  async with websockets.connect(websocket_url, ping_interval=None) as websocket:
131
63
  logger.info("TextHooker Websocket Connected!")
132
64
  if reconnecting:
133
- logger.info(f"Texthooker WebSocket connected Successfully!" + " Disabling Clipboard Monitor." if get_config().general.use_clipboard else "")
65
+ logger.info(f"Texthooker WebSocket connected Successfully!" + " Disabling Clipboard Monitor." if (get_config().general.use_clipboard and not get_config().general.use_both_clipboard_and_websocket) else "")
134
66
  reconnecting = False
135
67
  websocket_connected = True
136
68
  try_other = True
@@ -164,18 +96,17 @@ async def listen_websocket():
164
96
  await asyncio.sleep(5)
165
97
 
166
98
  def handle_new_text_event(current_clipboard, line_time=None):
167
- global current_line, current_line_time, line_history, current_line_after_regex
99
+ global current_line, current_line_time, current_line_after_regex
168
100
  current_line = current_clipboard
169
101
  if get_config().general.texthook_replacement_regex:
170
102
  current_line_after_regex = re.sub(get_config().general.texthook_replacement_regex, '', current_line)
171
103
  else:
172
104
  current_line_after_regex = current_line
105
+ current_line_after_regex = do_text_replacements(current_line, TEXT_REPLACEMENTS_FILE)
173
106
  logger.info(f"Line Received: {current_line_after_regex}")
174
107
  current_line_time = line_time if line_time else datetime.now()
175
- line_history.add_line(current_line_after_regex, line_time)
176
- if get_utility_window():
177
- get_utility_window().add_text(line_history[-1])
178
-
108
+ add_line(current_line_after_regex, line_time)
109
+ add_event_to_texthooker(get_text_log()[-1])
179
110
 
180
111
  def reset_line_hotkey_pressed():
181
112
  global current_line_time
@@ -193,78 +124,8 @@ def start_text_monitor():
193
124
  threading.Thread(target=run_websocket_listener, daemon=True).start()
194
125
  if get_config().general.use_clipboard:
195
126
  if get_config().general.use_websocket:
196
- logger.info("Both WebSocket and Clipboard monitoring are enabled. WebSocket will take precedence if connected.")
197
- ClipboardMonitor().start()
198
-
199
-
200
- def similar(a, b):
201
- return SequenceMatcher(None, a, b).ratio()
202
-
203
- def one_contains_the_other(a, b):
204
- return a in b or b in a
205
-
206
- def lines_match(a, b):
207
- similarity = similar(a, b)
208
- logger.debug(f"Comparing: {a} with {b} - Similarity: {similarity}, Or One contains the other: {one_contains_the_other(a, b)}")
209
- return similar(a, b) >= 0.60 or one_contains_the_other(a, b)
210
-
211
- def get_text_event(last_note) -> GameLine:
212
- lines = line_history.values
213
-
214
- if not lines:
215
- raise Exception("No lines in history. Text is required from either clipboard or websocket for GSM to work. Please check your setup/config.")
216
-
217
- if not last_note:
218
- return lines[-1]
219
-
220
- sentence = last_note.get_field(get_config().anki.sentence_field)
221
- if not sentence:
222
- return lines[-1]
223
-
224
- for line in reversed(lines):
225
- if lines_match(line.text, remove_html_and_cloze_tags(sentence)):
226
- return line
227
-
228
- logger.debug("Couldn't find a match in history, using last event")
229
- return lines[-1]
230
-
231
-
232
- def get_line_and_future_lines(last_note):
233
- if not last_note:
234
- return []
235
-
236
- sentence = last_note.get_field(get_config().anki.sentence_field)
237
- found_lines = []
238
- if sentence:
239
- found = False
240
- for line in line_history.values:
241
- if found:
242
- found_lines.append(line.text)
243
- if lines_match(line.text, remove_html_and_cloze_tags(sentence)): # 80% similarity threshold
244
- found = True
245
- found_lines.append(line.text)
246
- return found_lines
247
-
248
- def get_mined_line(last_note: AnkiCard, lines):
249
- if not last_note:
250
- return lines[-1]
251
- if not lines:
252
- lines = get_all_lines()
253
-
254
- sentence = last_note.get_field(get_config().anki.sentence_field)
255
- for line in lines:
256
- if lines_match(line.text, remove_html_and_cloze_tags(sentence)):
257
- return line
258
- return lines[-1]
259
-
260
-
261
- def get_time_of_line(line):
262
- return line_history.get_time(line)
263
-
264
-
265
- def get_all_lines():
266
- return line_history.values
267
-
268
-
269
- def get_line_history():
270
- return line_history
127
+ if get_config().general.use_both_clipboard_and_websocket:
128
+ logger.info("Listening for Text on both WebSocket and Clipboard.")
129
+ else:
130
+ logger.info("Both WebSocket and Clipboard monitoring are enabled. WebSocket will take precedence if connected.")
131
+ ClipboardMonitor().start()
GameSentenceMiner/gsm.py CHANGED
@@ -10,7 +10,6 @@ from pystray import Icon, Menu, MenuItem
10
10
  from watchdog.events import FileSystemEventHandler
11
11
  from watchdog.observers import Observer
12
12
 
13
- import time
14
13
 
15
14
  from GameSentenceMiner import anki
16
15
  from GameSentenceMiner import config_gui
@@ -27,10 +26,11 @@ from GameSentenceMiner.communication.websocket import connect_websocket, registe
27
26
  from GameSentenceMiner.configuration import *
28
27
  from GameSentenceMiner.downloader.download_tools import download_obs_if_needed, download_ffmpeg_if_needed
29
28
  from GameSentenceMiner.ffmpeg import get_audio_and_trim, get_video_timings
30
- from GameSentenceMiner.gametext import get_text_event, get_mined_line, GameLine
31
29
  from GameSentenceMiner.obs import check_obs_folder_is_correct
30
+ from GameSentenceMiner.text_log import GameLine, get_text_event, get_mined_line, get_all_lines
32
31
  from GameSentenceMiner.util import *
33
- from GameSentenceMiner.utility_gui import init_utility_window, get_utility_window
32
+ from GameSentenceMiner.web import texthooking_page
33
+ from GameSentenceMiner.web.texthooking_page import start_web_server
34
34
 
35
35
  if is_windows():
36
36
  import win32api
@@ -57,9 +57,9 @@ class VideoToAudioHandler(FileSystemEventHandler):
57
57
  @staticmethod
58
58
  def convert_to_audio(video_path):
59
59
  try:
60
- if get_utility_window().line_for_audio:
61
- line: GameLine = get_utility_window().line_for_audio
62
- get_utility_window().line_for_audio = None
60
+ if texthooking_page.event_manager.line_for_audio:
61
+ line: GameLine = texthooking_page.event_manager.line_for_audio
62
+ texthooking_page.event_manager.line_for_audio = None
63
63
  if get_config().advanced.audio_player_path:
64
64
  audio = VideoToAudioHandler.get_audio(line, line.next.time if line.next else None, video_path, temporary=True)
65
65
  play_audio_in_external(audio)
@@ -67,9 +67,9 @@ class VideoToAudioHandler(FileSystemEventHandler):
67
67
  elif get_config().advanced.video_player_path:
68
68
  play_video_in_external(line, video_path)
69
69
  return
70
- if get_utility_window().line_for_screenshot:
71
- line: GameLine = get_utility_window().line_for_screenshot
72
- get_utility_window().line_for_screenshot = None
70
+ if texthooking_page.event_manager.line_for_screenshot:
71
+ line: GameLine = texthooking_page.event_manager.line_for_screenshot
72
+ texthooking_page.event_manager.line_for_screenshot = None
73
73
  screenshot = ffmpeg.get_screenshot_for_line(video_path, line)
74
74
  os.startfile(screenshot)
75
75
  os.remove(video_path)
@@ -109,18 +109,18 @@ class VideoToAudioHandler(FileSystemEventHandler):
109
109
  if mined_line.next:
110
110
  line_cutoff = mined_line.next.time
111
111
 
112
- if get_utility_window().lines_selected():
113
- lines = get_utility_window().get_selected_lines()
114
- start_line = lines[0]
115
- mined_line = get_mined_line(last_note, lines)
116
- line_cutoff = get_utility_window().get_next_line_timing()
112
+ selected_lines = []
113
+ if texthooking_page.are_lines_selected():
114
+ selected_lines = texthooking_page.get_selected_lines()
115
+ start_line = selected_lines[0]
116
+ mined_line = get_mined_line(last_note, selected_lines)
117
+ line_cutoff = selected_lines[-1].get_next_time()
117
118
 
118
119
  if last_note:
119
120
  logger.debug(last_note.to_json())
120
- selected_lines = get_utility_window().get_selected_lines()
121
121
  note = anki.get_initial_card_info(last_note, selected_lines)
122
122
  tango = last_note.get_field(get_config().anki.word_field) if last_note else ''
123
- get_utility_window().reset_checkboxes()
123
+ texthooking_page.reset_checked_lines()
124
124
 
125
125
  if get_config().anki.sentence_audio_field and get_config().audio.enabled:
126
126
  logger.debug("Attempting to get audio from video")
@@ -268,10 +268,10 @@ def register_hotkeys():
268
268
  keyboard.add_hotkey(get_config().hotkeys.reset_line, gametext.reset_line_hotkey_pressed)
269
269
  if get_config().hotkeys.take_screenshot:
270
270
  keyboard.add_hotkey(get_config().hotkeys.take_screenshot, get_screenshot)
271
- if get_config().hotkeys.open_utility:
272
- keyboard.add_hotkey(get_config().hotkeys.open_utility, open_multimine)
273
271
  if get_config().hotkeys.play_latest_audio:
274
272
  keyboard.add_hotkey(get_config().hotkeys.play_latest_audio, play_most_recent_audio)
273
+ if get_config().hotkeys.open_utility:
274
+ keyboard.add_hotkey(get_config().hotkeys.open_utility, texthooking_page.open_texthooker)
275
275
 
276
276
 
277
277
  def get_screenshot():
@@ -322,13 +322,10 @@ def open_settings():
322
322
  settings_window.show()
323
323
 
324
324
 
325
- def open_multimine():
326
- obs.update_current_game()
327
- get_utility_window().show()
328
-
329
325
  def play_most_recent_audio():
330
- if get_config().advanced.audio_player_path or get_config().advanced.video_player_path and len(gametext.line_history.values) > 0:
331
- get_utility_window().line_for_audio = gametext.line_history.values[-1]
326
+ if get_config().advanced.audio_player_path or get_config().advanced.video_player_path and len(
327
+ get_all_lines()) > 0:
328
+ texthooking_page.event_manager.line_for_audio = get_all_lines()[-1]
332
329
  obs.save_replay_buffer()
333
330
  else:
334
331
  logger.error("Feature Disabled. No audio or video player path set in config!")
@@ -368,6 +365,10 @@ def play_pause(icon, item):
368
365
  update_icon()
369
366
 
370
367
 
368
+ def open_multimine(icon, item):
369
+ texthooking_page.open_texthooker()
370
+
371
+
371
372
  def update_icon():
372
373
  global menu, icon
373
374
  # Recreate the menu with the updated button text
@@ -416,7 +417,7 @@ def run_tray():
416
417
 
417
418
  menu = Menu(
418
419
  MenuItem("Open Settings", open_settings),
419
- MenuItem("Open Multi-Mine GUI", open_multimine),
420
+ MenuItem("Open Texthooker", texthooking_page.open_texthooker),
420
421
  MenuItem("Open Log", open_log),
421
422
  MenuItem("Toggle Replay Buffer", play_pause),
422
423
  MenuItem("Restart OBS", restart_obs),
@@ -554,6 +555,7 @@ def post_init():
554
555
  whisper_helper.initialize_whisper_model()
555
556
  if get_config().vad.is_silero():
556
557
  from GameSentenceMiner.vad import silero_trim
558
+ start_web_server()
557
559
 
558
560
  util.run_new_thread(do_post_init)
559
561
 
@@ -576,7 +578,6 @@ def main(reloading=False):
576
578
  logger.info("Script started.")
577
579
  root = ttk.Window(themename='darkly')
578
580
  settings_window = config_gui.ConfigApp(root)
579
- init_utility_window(root)
580
581
  initialize(reloading)
581
582
  initialize_async()
582
583
  observer = Observer()
@@ -594,9 +595,7 @@ def main(reloading=False):
594
595
  try:
595
596
  # if get_config().general.open_config_on_startup:
596
597
  # root.after(0, settings_window.show)
597
- if get_config().general.open_multimine_on_startup:
598
- root.after(0, get_utility_window().show)
599
- root.after(0, post_init)
598
+ root.after(50, post_init)
600
599
  settings_window.add_save_hook(update_icon)
601
600
  settings_window.on_exit = exit_program
602
601
  root.mainloop()
GameSentenceMiner/obs.py CHANGED
@@ -1,10 +1,7 @@
1
- import logging
2
1
  import os.path
3
2
  import subprocess
4
- import tempfile
5
3
  import time
6
4
 
7
- import psutil
8
5
  from obswebsocket import obsws, requests
9
6
 
10
7
  from GameSentenceMiner import util, configuration
@@ -1,6 +1,5 @@
1
1
  import configparser
2
2
  import os
3
- import re
4
3
 
5
4
  class OCRConfig:
6
5
  def __init__(self, config_file=os.path.expanduser("~/.config/owocr_config.ini")):