GameSentenceMiner 2.3.0__py3-none-any.whl → 2.3.1__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.
GameSentenceMiner/anki.py CHANGED
@@ -12,6 +12,7 @@ from GameSentenceMiner.configuration import *
12
12
  from GameSentenceMiner.configuration import get_config
13
13
  from GameSentenceMiner.gametext import get_last_two_sentences
14
14
  from GameSentenceMiner.obs import get_current_game
15
+ from util import remove_html_tags
15
16
 
16
17
  audio_in_anki = None
17
18
  screenshot_in_anki = None
@@ -69,6 +70,8 @@ def update_anki_card(last_note, note=None, audio_path='', video_path='', tango='
69
70
  if get_config().features.open_anki_edit:
70
71
  notification.open_anki_card(last_note['noteId'])
71
72
 
73
+ util.set_last_mined_line(get_sentence(last_note))
74
+
72
75
  if get_config().audio.external_tool:
73
76
  open_audio_in_external(f"{get_config().audio.anki_media_collection}/{audio_in_anki}")
74
77
 
@@ -110,12 +113,9 @@ def get_initial_card_info(last_note, selected_lines):
110
113
  current_line, previous_line = get_last_two_sentences(last_note)
111
114
  logger.debug(f"Previous Sentence {previous_line}")
112
115
  logger.debug(f"Current Sentence {current_line}")
113
- util.use_previous_audio = True
114
116
 
115
117
  if get_config().audio.mining_from_history_grab_all_audio and get_config().anki.multi_overwrites_sentence:
116
118
  lines = gametext.get_line_and_future_lines(last_note)
117
- logger.info(lines)
118
- logger.info("".join(lines))
119
119
  if lines:
120
120
  note['fields'][get_config().anki.sentence_field] = "".join(lines)
121
121
 
@@ -212,11 +212,11 @@ def update_new_card():
212
212
  if not check_tags_for_should_update(last_card):
213
213
  return
214
214
 
215
- use_prev_audio = util.use_previous_audio
216
215
  if util.lock.locked():
217
216
  logger.info("Audio still being Trimmed, Card Queued!")
218
- use_prev_audio = True
219
217
  with util.lock:
218
+ use_prev_audio = sentence_is_same_as_previous(last_card)
219
+ logger.info(f"last mined line: {util.get_last_mined_line()}, current sentence: {get_sentence(last_card)}")
220
220
  logger.info(f"use previous audio: {use_prev_audio}")
221
221
  if get_config().obs.get_game_from_scene:
222
222
  obs.update_current_game()
@@ -226,6 +226,13 @@ def update_new_card():
226
226
  logger.info("New card(s) detected!")
227
227
  obs.save_replay_buffer()
228
228
 
229
+ def sentence_is_same_as_previous(last_card):
230
+ if not util.get_last_mined_line():
231
+ return False
232
+ return remove_html_tags(get_sentence(last_card)) == remove_html_tags(util.get_last_mined_line())
233
+
234
+ def get_sentence(card):
235
+ return card['fields'][get_config().anki.sentence_field]['value']
229
236
 
230
237
  def check_tags_for_should_update(last_card):
231
238
  if get_config().anki.tags_to_check:
@@ -184,6 +184,8 @@ class ConfigApp:
184
184
  ),
185
185
  obs=OBS(
186
186
  enabled=self.obs_enabled.get(),
187
+ open_obs=self.open_obs.get(),
188
+ close_obs=self.close_obs.get(),
187
189
  host=self.obs_host.get(),
188
190
  port=int(self.obs_port.get()),
189
191
  password=self.obs_password.get(),
@@ -766,6 +768,18 @@ class ConfigApp:
766
768
  self.add_label_and_increment_row(obs_frame, "Enable or disable OBS integration.", row=self.current_row,
767
769
  column=2)
768
770
 
771
+ ttk.Label(obs_frame, text="Open OBS:").grid(row=self.current_row, column=0, sticky='W')
772
+ self.open_obs = tk.BooleanVar(value=self.settings.obs.open_obs)
773
+ ttk.Checkbutton(obs_frame, variable=self.open_obs).grid(row=self.current_row, column=1, sticky='W')
774
+ self.add_label_and_increment_row(obs_frame, "Open OBS when the GSM starts.", row=self.current_row,
775
+ column=2)
776
+
777
+ ttk.Label(obs_frame, text="Close OBS:").grid(row=self.current_row, column=0, sticky='W')
778
+ self.close_obs = tk.BooleanVar(value=self.settings.obs.close_obs)
779
+ ttk.Checkbutton(obs_frame, variable=self.close_obs).grid(row=self.current_row, column=1, sticky='W')
780
+ self.add_label_and_increment_row(obs_frame, "Close OBS when the GSM closes.", row=self.current_row,
781
+ column=2)
782
+
769
783
  ttk.Label(obs_frame, text="Host:").grid(row=self.current_row, column=0, sticky='W')
770
784
  self.obs_host = ttk.Entry(obs_frame)
771
785
  self.obs_host.insert(0, self.settings.obs.host)
@@ -121,6 +121,8 @@ class Audio:
121
121
  @dataclass
122
122
  class OBS:
123
123
  enabled: bool = True
124
+ open_obs: bool = True
125
+ close_obs: bool = False
124
126
  host: str = "localhost"
125
127
  port: int = 4455
126
128
  password: str = "your_password"
@@ -9,7 +9,6 @@ from typing import Callable
9
9
  import pyperclip
10
10
  import websockets
11
11
 
12
- from GameSentenceMiner import util
13
12
  from GameSentenceMiner.configuration import *
14
13
  from GameSentenceMiner.configuration import get_config, logger
15
14
  from GameSentenceMiner.util import remove_html_tags
@@ -80,7 +79,6 @@ def handle_new_text_event(current_clipboard):
80
79
  current_line_after_regex = current_line
81
80
  current_line_time = datetime.now()
82
81
  line_history[current_line_after_regex] = current_line_time
83
- util.use_previous_audio = False
84
82
  multi_mine_event_bus(current_line_after_regex, current_line_time)
85
83
  logger.debug(f"New Line: {current_clipboard}")
86
84
 
@@ -90,7 +88,6 @@ def reset_line_hotkey_pressed():
90
88
  logger.info("LINE RESET HOTKEY PRESSED")
91
89
  current_line_time = datetime.now()
92
90
  line_history[current_line_after_regex] = current_line_time
93
- util.use_previous_audio = False
94
91
 
95
92
 
96
93
  def run_websocket_listener():
GameSentenceMiner/gsm.py CHANGED
@@ -64,7 +64,6 @@ class VideoToAudioHandler(FileSystemEventHandler):
64
64
  logger.error(
65
65
  f"Video was unusually small, potentially empty! Check OBS for Correct Scene Settings! Path: {video_path}")
66
66
  return
67
- util.use_previous_audio = True
68
67
  last_note = None
69
68
  logger.debug("Attempting to get last anki card")
70
69
  if get_config().anki.update_anki:
@@ -157,7 +156,8 @@ def initialize(reloading=False):
157
156
  download_obs_if_needed()
158
157
  download_ffmpeg_if_needed()
159
158
  if get_config().obs.enabled:
160
- obs_process = obs.start_obs()
159
+ if get_config().obs.open_obs:
160
+ obs_process = obs.start_obs()
161
161
  obs.connect_to_obs(start_replay=True)
162
162
  anki.start_monitoring_anki()
163
163
  gametext.start_text_monitor(utility_window.add_text)
@@ -344,7 +344,8 @@ def cleanup():
344
344
  if get_config().obs.start_buffer:
345
345
  obs.stop_replay_buffer()
346
346
  obs.disconnect_from_obs()
347
- close_obs()
347
+ if get_config().obs.close_obs:
348
+ close_obs()
348
349
 
349
350
  proc: Popen
350
351
  for proc in procs_to_close:
GameSentenceMiner/util.py CHANGED
@@ -14,10 +14,16 @@ from GameSentenceMiner.configuration import logger
14
14
  SCRIPTS_DIR = r"E:\Japanese Stuff\agent-v0.1.4-win32-x64\data\scripts"
15
15
 
16
16
  # Global variables to control script execution
17
- use_previous_audio = False
18
17
  keep_running = True
19
18
  lock = threading.Lock()
19
+ last_mined_line = None
20
20
 
21
+ def get_last_mined_line():
22
+ return last_mined_line
23
+
24
+ def set_last_mined_line(line):
25
+ global last_mined_line
26
+ last_mined_line = line
21
27
 
22
28
  def run_new_thread(func):
23
29
  thread = threading.Thread(target=func, daemon=True)
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: GameSentenceMiner
3
- Version: 2.3.0
4
- Summary: A tool for mining sentences from games. Update: Multi-Line Mining!
3
+ Version: 2.3.1
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
7
7
  Project-URL: Homepage, https://github.com/bpwhelan/GameSentenceMiner
@@ -1,15 +1,15 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=895FTnqZCn2AmfUqxWKsSOkzumFoPRNhwPRf00mB7OI,9755
3
- GameSentenceMiner/config_gui.py,sha256=IYM_qZV22Hn_eGbXIqrQx2r7UGlTFDLBa0bqu3HqFl0,52491
4
- GameSentenceMiner/configuration.py,sha256=X61ks7iuzf0Wu7U4QuhggUGB9-1KLka-V4cduoEOddA,14294
2
+ GameSentenceMiner/anki.py,sha256=gpd_af7zrwuGyIfMAPvunZW1I0mVG2MBemVnikTVp5c,10151
3
+ GameSentenceMiner/config_gui.py,sha256=B37GPeGtGNTJgFTor3M01Tw2iZYRRtHLYck6Q83-JRg,53460
4
+ GameSentenceMiner/configuration.py,sha256=x50-InaGl70dHpWhdOAZJTIKj84EtVfTqEmIFCnDcvw,14348
5
5
  GameSentenceMiner/ffmpeg.py,sha256=VExJYWSFhYuWukIXgOiHufsoSROEDA8LnVQFG8srRGc,10924
6
- GameSentenceMiner/gametext.py,sha256=ci1ZTwObi-5pxFWHcXp1cDWMrCz_zaPtUsWvTO_jwRU,6570
7
- GameSentenceMiner/gsm.py,sha256=GY9T3h2dwY-XofXqESiyZpezRvlfaZrhzo0PDuuE87g,17065
6
+ GameSentenceMiner/gametext.py,sha256=ckZGOHpGuvFE2zDNdaASSaMYi4JCFsyG2kYKCbZIQPo,6463
7
+ GameSentenceMiner/gsm.py,sha256=l92vu9P06v5crBfka-TGjlSyqM7WG2ND4ZzWQVTY7ws,17103
8
8
  GameSentenceMiner/model.py,sha256=oh8VVT8T1UKekbmP6MGNgQ8jIuQ_7Rg4GPzDCn2kJo8,1999
9
9
  GameSentenceMiner/notification.py,sha256=WBaQWoPNhW4XqdPBUmxPBgjk0ngzH_4v9zMQ-XQAKC8,2010
10
10
  GameSentenceMiner/obs.py,sha256=3Flcjxy812VpF78EPI7sxlGx6yyM3GfqzlinW17SK20,6231
11
11
  GameSentenceMiner/package_updater.py,sha256=0uaLAp0WrWqostNTBWRS0laITjI9aN9Yt_6GXosS4NQ,1278
12
- GameSentenceMiner/util.py,sha256=cgKpPfRpouWI6tjE_35MWp8nXqRzXs3LvsYXWm5_DOg,4584
12
+ GameSentenceMiner/util.py,sha256=MITweiFYaefWQF5nR8tZ9yE6vd_b-fLuP0MP1Y1U4K0,4720
13
13
  GameSentenceMiner/utility_gui.py,sha256=-T5b14Nx6KvNnBEmdVz0mWkXoYi-bZzHIce6ADwfVEQ,4701
14
14
  GameSentenceMiner/downloader/Untitled_json.py,sha256=RUUl2bbbCpUDUUS0fP0tdvf5FngZ7ILdA_J5TFYAXUQ,15272
15
15
  GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -18,8 +18,8 @@ GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
18
18
  GameSentenceMiner/vad/silero_trim.py,sha256=syDJX_KbFmdyFFtnQqYTD0tICsUCJizYhs-atPgXtxA,1549
19
19
  GameSentenceMiner/vad/vosk_helper.py,sha256=-AAwK0cgOC5rK3_gL0sQgrPJ75E49g_PxZR4d5ckwc4,5826
20
20
  GameSentenceMiner/vad/whisper_helper.py,sha256=bpR1HVnJRn9H5u8XaHBqBJ6JwIjzqn-Fajps8QmQ4zc,3411
21
- GameSentenceMiner-2.3.0.dist-info/METADATA,sha256=isZtUWBqPSC2Q-MG3HbL9aUT4uAbjHIiXhJFSYSR4mg,10113
22
- GameSentenceMiner-2.3.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
23
- GameSentenceMiner-2.3.0.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
24
- GameSentenceMiner-2.3.0.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
25
- GameSentenceMiner-2.3.0.dist-info/RECORD,,
21
+ GameSentenceMiner-2.3.1.dist-info/METADATA,sha256=UN9Pn6JrUpTuIeMRBT3CAizAUNmVM9aTKw6DCBwxTOg,10120
22
+ GameSentenceMiner-2.3.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
23
+ GameSentenceMiner-2.3.1.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
24
+ GameSentenceMiner-2.3.1.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
25
+ GameSentenceMiner-2.3.1.dist-info/RECORD,,