GameSentenceMiner 2.18.4__py3-none-any.whl → 2.18.5__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.

Potentially problematic release.


This version of GameSentenceMiner might be problematic. Click here for more details.

GameSentenceMiner/obs.py CHANGED
@@ -132,11 +132,14 @@ class OBSConnectionManager(threading.Thread):
132
132
 
133
133
  def check_replay_buffer_enabled(self):
134
134
  if not self.should_check_output:
135
- return True, ""
136
- output = get_replay_buffer_output()
137
- if not output:
138
- return False, "Replay Buffer output not found in OBS. Please enable Replay Buffer In OBS Settings -> Output -> Replay Buffer. I recommend 300 seconds (5 minutes) or higher."
139
- return True, ""
135
+ return 300, ""
136
+ buffer_seconds = get_replay_buffer_max_time_seconds()
137
+ if not buffer_seconds:
138
+ replay_output = get_replay_buffer_output()
139
+ if not replay_output:
140
+ return 0, "Replay Buffer output not found in OBS. Please enable Replay Buffer In OBS Settings -> Output -> Replay Buffer. I recommend 300 seconds (5 minutes) or higher."
141
+ return 300, ""
142
+ return buffer_seconds, ""
140
143
 
141
144
  def _manage_replay_buffer_and_utils(self):
142
145
  errors = []
@@ -150,11 +153,13 @@ class OBSConnectionManager(threading.Thread):
150
153
  errors.append("Automatic Replay Buffer management is disabled in GSM settings.")
151
154
  return errors
152
155
 
153
- replay_buffer_enabled, error_message = self.check_replay_buffer_enabled()
156
+ buffer_seconds, error_message = self.check_replay_buffer_enabled()
154
157
 
155
- if not replay_buffer_enabled:
158
+ if not buffer_seconds:
156
159
  errors.append(error_message)
157
160
  return errors
161
+
162
+ self.NO_OUTPUT_SHUTDOWN_SECONDS = max(300, buffer_seconds * 1.10) # At least 5 minutes or 10% more than buffer
158
163
 
159
164
  current_status = get_replay_buffer_status()
160
165
 
@@ -167,10 +172,10 @@ class OBSConnectionManager(threading.Thread):
167
172
  self.no_output_timestamp = None
168
173
  return errors
169
174
 
170
- img = get_screenshot_PIL(compression=100, img_format='jpg', width=1280, height=720)
171
- has_changed = self.has_image_changed(img) if img else True
175
+ img = get_screenshot_PIL(compression=75, img_format='jpg', width=1280, height=720)
176
+ is_empty = self.is_image_empty(img) if img else True
172
177
 
173
- if not has_changed:
178
+ if not is_empty:
174
179
  self.no_output_timestamp = None
175
180
  if not current_status:
176
181
  start_replay_buffer()
@@ -184,20 +189,18 @@ class OBSConnectionManager(threading.Thread):
184
189
  self.last_replay_buffer_status = False
185
190
  self.no_output_timestamp = None
186
191
 
187
- def has_image_changed(self, img):
188
- if self.previous_image is None:
189
- self.previous_image = np.array(img)
190
- return True
192
+ def is_image_empty(self, img):
191
193
  try:
192
- img1_np = np.array(img) if not isinstance(img, np.ndarray) else img
193
- img2_np = self.previous_image
194
- self.previous_image = img1_np
194
+ extrema = img.getextrema()
195
+ if isinstance(extrema[0], tuple):
196
+ is_empty = all(e[0] == e[1] for e in extrema)
197
+ else:
198
+ is_empty = extrema[0] == extrema[1]
199
+ return is_empty
195
200
  except Exception:
196
- logger.warning("Failed to convert images to numpy arrays for comparison.")
201
+ logger.warning("Failed to check image extrema for emptiness.")
197
202
  return False
198
203
 
199
- return (img1_np.shape == img2_np.shape) and np.array_equal(img1_np, img2_np)
200
-
201
204
  def run(self):
202
205
  time.sleep(5) # Initial delay to allow OBS to start
203
206
  while self.running:
@@ -566,7 +569,7 @@ def get_replay_buffer_max_time_seconds():
566
569
  logger.warning(f"get_output_settings for replay_buffer failed: {response.status}")
567
570
  return 0
568
571
  except Exception as e:
569
- logger.error(f"Exception while fetching replay buffer settings: {e}")
572
+ # logger.error(f"Exception while fetching replay buffer settings: {e}")
570
573
  return 0
571
574
 
572
575
  def enable_replay_buffer():
@@ -805,7 +808,24 @@ def set_fit_to_screen_for_scene_items(scene_name: str):
805
808
  except obs.error.OBSSDKError as e:
806
809
  logger.error(f"An OBS error occurred: {e}")
807
810
  except Exception as e:
808
- logger.error(f"An unexpected error occurred: {e}")
811
+ logger.error(f"An unexpected error occurred: {e}")
812
+
813
+ def get_current_source_input_settings():
814
+ with connection_pool.get_client() as client:
815
+ client: obs.ReqClient
816
+ current_scene = get_current_scene()
817
+ if not current_scene:
818
+ return None
819
+ scene_items_response = client.get_scene_item_list(name=current_scene)
820
+ items = scene_items_response.scene_items if scene_items_response and scene_items_response.scene_items else []
821
+ if not items:
822
+ return None
823
+ first_item = items[0]
824
+ source_name = first_item.get('sourceName')
825
+ if not source_name:
826
+ return None
827
+ input_settings_response = client.get_input_settings(name=source_name)
828
+ return input_settings_response.input_settings if input_settings_response else None
809
829
 
810
830
 
811
831
  def main():
@@ -867,17 +887,23 @@ if __name__ == '__main__':
867
887
  logging.basicConfig(level=logging.INFO)
868
888
  connect_to_obs_sync()
869
889
 
870
- save_replay_buffer()
890
+ # outputs = get_output_list()
891
+ # print(outputs)
892
+
893
+ # output = get_replay_buffer_output()
894
+ # print(output)
895
+
896
+ # save_replay_buffer()
871
897
  # img = get_screenshot_PIL(source_name='Display Capture 2', compression=100, img_format='jpg', width=2560, height=1440)
872
898
  # img.show()
873
- # output_list = get_output_list()
874
- # print(output_list)
899
+ # source = get_current_source_input_settings()
900
+ # print(source)
875
901
 
876
902
  # response = enable_replay_buffer()
877
903
  # print(response)
878
904
 
879
905
  # response = get_replay_buffer_max_time_seconds()
880
- # # response is dataclass with attributes, print attributes
906
+ # response is dataclass with attributes, print attributes
881
907
  # print(response)
882
908
 
883
909
  # response = enable_replay_buffer()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.18.4
3
+ Version: 2.18.5
4
4
  Summary: A tool for mining sentences from games. Update: Overlay?
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -2,7 +2,7 @@ GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
2
2
  GameSentenceMiner/anki.py,sha256=TgLJIGZq6qPfmXV378BzG_SEnL6KvHK74u4ztTggzbM,31139
3
3
  GameSentenceMiner/gametext.py,sha256=FBL3kgJ71hCg5Nczuo9dAEi_sLGdVIGgvc62bT5KhCc,10691
4
4
  GameSentenceMiner/gsm.py,sha256=0hEpEBDbI9FtiKtHeyrSLKV1nys-mKTKfxLY0Dk7mOQ,36387
5
- GameSentenceMiner/obs.py,sha256=R2Rsq2rMnWIoIb4tArTY7oAFIsyxfp1Nf-XnX_E95io,35858
5
+ GameSentenceMiner/obs.py,sha256=Ru0523AYqJhZG3oKrDzw-7dQszCRjAKgS06yV5fKvcs,36886
6
6
  GameSentenceMiner/vad.py,sha256=dhZpbTsVI4scqXZ0M701BenUur0EzYM96tnyGXo8iI0,21021
7
7
  GameSentenceMiner/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  GameSentenceMiner/ai/ai_prompting.py,sha256=mq9Odv_FpohXagU-OoSZbLWttdrEl1M1NiqnodeUpD8,29126
@@ -124,9 +124,9 @@ GameSentenceMiner/web/templates/components/kanji_grid/thousand_character_classic
124
124
  GameSentenceMiner/web/templates/components/kanji_grid/wanikani_levels.json,sha256=8wjnnaYQqmho6t5tMxrIAc03512A2tYhQh5dfsQnfAM,11372
125
125
  GameSentenceMiner/web/templates/components/kanji_grid/words_hk_frequency_list.json,sha256=wRkqZNPzz6DT9OTPHpXwfqW96Qb96stCQNNgOL-ZdKk,17535
126
126
  GameSentenceMiner/wip/__init___.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
127
- gamesentenceminer-2.18.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
128
- gamesentenceminer-2.18.4.dist-info/METADATA,sha256=SXw7P4busY00L4EwV-Avnt2C29HYJGLoePm5WBEgIo8,7487
129
- gamesentenceminer-2.18.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
130
- gamesentenceminer-2.18.4.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
131
- gamesentenceminer-2.18.4.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
132
- gamesentenceminer-2.18.4.dist-info/RECORD,,
127
+ gamesentenceminer-2.18.5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
128
+ gamesentenceminer-2.18.5.dist-info/METADATA,sha256=92I3vL7iPRi0A-TfwXVAETyk3ZzipuX-ZdiyiXkK4_k,7487
129
+ gamesentenceminer-2.18.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
130
+ gamesentenceminer-2.18.5.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
131
+ gamesentenceminer-2.18.5.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
132
+ gamesentenceminer-2.18.5.dist-info/RECORD,,