GameSentenceMiner 2.8.30__py3-none-any.whl → 2.8.33__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
@@ -45,14 +45,7 @@ def update_anki_card(last_note: AnkiCard, note=None, audio_path='', video_path='
45
45
  if get_config().paths.remove_screenshot:
46
46
  os.remove(screenshot)
47
47
  if get_config().anki.previous_image_field:
48
- if prev_ss_timing != 0:
49
- try:
50
- prev_screenshot = ffmpeg.get_screenshot(video_path, prev_ss_timing)
51
- except Exception as e:
52
- logger.error(f"Error getting previous screenshot based on VAD, Falling back to previous logic: {e}")
53
- prev_screenshot = ffmpeg.get_screenshot(video_path, ffmpeg.get_screenshot_time(video_path, selected_lines[0].prev if selected_lines else game_line.prev))
54
- else:
55
- prev_screenshot = ffmpeg.get_screenshot(video_path, ffmpeg.get_screenshot_time(video_path, selected_lines[0].prev if selected_lines else game_line.prev))
48
+ prev_screenshot = ffmpeg.get_screenshot_for_line(video_path, selected_lines[0].prev if selected_lines else game_line.prev)
56
49
  prev_screenshot_in_anki = store_media_file(prev_screenshot)
57
50
  if get_config().paths.remove_screenshot:
58
51
  os.remove(prev_screenshot)
@@ -777,7 +777,7 @@ class ConfigApp:
777
777
  self.seconds_after_line = ttk.Entry(screenshot_frame)
778
778
  self.seconds_after_line.insert(0, str(self.settings.screenshot.seconds_after_line))
779
779
  self.seconds_after_line.grid(row=self.current_row, column=1)
780
- self.add_label_and_increment_row(screenshot_frame, "Time in seconds to offset the screenshot based on the Timing setting above (should almost always be positive)", row=self.current_row,
780
+ self.add_label_and_increment_row(screenshot_frame, "Time in seconds to offset the screenshot based on the Timing setting above (should almost always be positive, can be negative if you use \"middle\")", row=self.current_row,
781
781
  column=2)
782
782
 
783
783
  # ttk.Label(screenshot_frame, text="Use Beginning of Line as Screenshot:").grid(row=self.current_row, column=0, sticky='W')
@@ -70,10 +70,10 @@ def get_screenshot_time(video_path, game_line, default_beginning=False, vad_resu
70
70
  screenshot_offset = get_config().screenshot.seconds_after_line
71
71
 
72
72
  # Calculate screenshot time from the beginning by adding the offset
73
- if vad_result and vad_result.success and not doing_multi_line:
74
- screenshot_time_from_beginning = line_timestamp_in_video + vad_result.end - 1
75
- logger.info(f"Using VAD result {vad_result} for screenshot time: {screenshot_time_from_beginning} seconds from beginning of replay")
76
- elif get_config().screenshot.screenshot_timing_setting == "beginning":
73
+ # if vad_result and vad_result.success and not doing_multi_line:
74
+ # screenshot_time_from_beginning = line_timestamp_in_video + vad_result.end - 1
75
+ # logger.info(f"Using VAD result {vad_result} for screenshot time: {screenshot_time_from_beginning} seconds from beginning of replay")
76
+ if get_config().screenshot.screenshot_timing_setting == "beginning":
77
77
  screenshot_time_from_beginning = line_timestamp_in_video + screenshot_offset
78
78
  logger.info(f"Using 'beginning' setting for screenshot time: {screenshot_time_from_beginning} seconds from beginning of replay")
79
79
  elif get_config().screenshot.screenshot_timing_setting == "middle":
GameSentenceMiner/gsm.py CHANGED
@@ -151,14 +151,14 @@ class VideoToAudioHandler(FileSystemEventHandler):
151
151
  logger.info("No SentenceAudio Field in config, skipping audio processing!")
152
152
 
153
153
  ss_timing = ffmpeg.get_screenshot_time(video_path, mined_line, vad_result=vad_result, doing_multi_line=bool(selected_lines))
154
- prev_ss_timing = 0
155
- if get_config().anki.previous_image_field and get_config().vad.do_vad_postprocessing:
156
- prev_ss_timing = ffmpeg.get_screenshot_time(video_path, mined_line.prev,
157
- vad_result=VideoToAudioHandler.get_audio(game_line=mined_line.prev,
158
- next_line_time=mined_line.time,
159
- video_path=video_path,
160
- anki_card_creation_time=anki_card_creation_time,
161
- timing_only=True) ,doing_multi_line=bool(selected_lines), previous_line=True)
154
+ # prev_ss_timing = 0
155
+ # if get_config().anki.previous_image_field and get_config().vad.do_vad_postprocessing:
156
+ # prev_ss_timing = ffmpeg.get_screenshot_time(video_path, mined_line.prev,
157
+ # vad_result=VideoToAudioHandler.get_audio(game_line=mined_line.prev,
158
+ # next_line_time=mined_line.time,
159
+ # video_path=video_path,
160
+ # anki_card_creation_time=anki_card_creation_time,
161
+ # timing_only=True) ,doing_multi_line=bool(selected_lines), previous_line=True)
162
162
 
163
163
  if get_config().anki.update_anki and last_note:
164
164
  anki.update_anki_card(last_note, note, audio_path=final_audio_output, video_path=video_path,
@@ -166,8 +166,7 @@ class VideoToAudioHandler(FileSystemEventHandler):
166
166
  should_update_audio=vad_result.success,
167
167
  ss_time=ss_timing,
168
168
  game_line=start_line,
169
- selected_lines=selected_lines,
170
- prev_ss_timing=prev_ss_timing)
169
+ selected_lines=selected_lines)
171
170
  elif get_config().features.notify_on_update and vad_result.success:
172
171
  notification.send_audio_generated_notification(vad_trimmed_audio)
173
172
  except Exception as e:
@@ -1,3 +1,4 @@
1
+ import ctypes
1
2
  from dataclasses import dataclass
2
3
  from math import floor, ceil
3
4
 
@@ -49,6 +50,7 @@ class OCRConfig:
49
50
  if self.coordinate_system and self.coordinate_system == "percentage" and self.window:
50
51
  import pygetwindow as gw
51
52
  try:
53
+ ctypes.windll.shcore.SetProcessDpiAwareness(2)
52
54
  window = gw.getWindowsWithTitle(self.window)[0]
53
55
  self.window_geometry = WindowGeometry(
54
56
  left=window.left,
@@ -56,6 +58,7 @@ class OCRConfig:
56
58
  width=window.width,
57
59
  height=window.height,
58
60
  )
61
+ print(f"Window '{self.window}' found with geometry: {self.window_geometry}")
59
62
  except IndexError:
60
63
  raise ValueError(f"Window with title '{self.window}' not found.")
61
64
  for rectangle in self.rectangles:
@@ -1,3 +1,4 @@
1
+ import ctypes
1
2
  import json
2
3
  import sys
3
4
  from multiprocessing import Process, Manager
@@ -856,6 +857,7 @@ def get_screen_selection(window_name):
856
857
  if __name__ == "__main__":
857
858
  target_window_title = None # Default to absolute coordinates
858
859
  # Check for command line arguments to specify window title
860
+ ctypes.windll.shcore.SetProcessDpiAwareness(2)
859
861
  if len(sys.argv) > 1:
860
862
  target_window_title = sys.argv[1]
861
863
  print(f"Attempting to target window title from args: '{target_window_title}'")
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import ctypes
2
3
  import json
3
4
  import logging
4
5
  import os
@@ -366,6 +367,7 @@ if __name__ == "__main__":
366
367
  logger.info(f"Received arguments: ocr1={ocr1}, ocr2={ocr2}, twopassocr={twopassocr}")
367
368
  global ocr_config
368
369
  ocr_config: OCRConfig = get_ocr_config()
370
+ ctypes.windll.shcore.SetProcessDpiAwareness(2)
369
371
  if ocr_config:
370
372
  if ocr_config.window:
371
373
  start_time = time.time()
@@ -377,7 +379,7 @@ if __name__ == "__main__":
377
379
  else:
378
380
  logger.error(f"Window '{ocr_config.window}' not found within 30 seconds.")
379
381
  sys.exit(1)
380
- logger.info(f"Starting OCR with configuration: Window: {ocr_config.window}, Rectangles: {len(ocr_config.rectangles)}, Engine 1: {ocr1}, Engine 2: {ocr2}, Two-pass OCR: {twopassocr}")
382
+ logger.info(f"Starting OCR with configuration: Window: {ocr_config.window}, Rectangles: {ocr_config.rectangles}, Engine 1: {ocr1}, Engine 2: {ocr2}, Two-pass OCR: {twopassocr}")
381
383
  if ocr_config:
382
384
  rectangles = list(filter(lambda rect: not rect.is_excluded, ocr_config.rectangles))
383
385
  last_ocr1_results = [""] * len(rectangles) if rectangles else [""]
@@ -53,8 +53,7 @@ except ImportError:
53
53
  pass
54
54
  from .config import Config
55
55
  from .screen_coordinate_picker import get_screen_selection
56
- from ...configuration import get_temporary_directory
57
-
56
+ from ...configuration import get_temporary_directory, get_app_directory
58
57
 
59
58
  config = None
60
59
 
@@ -513,7 +512,7 @@ class ScreenshotClass:
513
512
  if not self.window_handle:
514
513
  raise ValueError(area_invalid_error)
515
514
 
516
- ctypes.windll.shcore.SetProcessDpiAwareness(1)
515
+ ctypes.windll.shcore.SetProcessDpiAwareness(2)
517
516
 
518
517
  self.windows_window_tracker_instance = threading.Thread(target=self.windows_window_tracker)
519
518
  self.windows_window_tracker_instance.start()
@@ -693,11 +692,11 @@ class ScreenshotClass:
693
692
  sct_img = self.sct.grab(self.sct_params)
694
693
  img = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX')
695
694
 
696
- # import random # Ensure this is imported at the top of the file if not already
697
- # rand_int = random.randint(1, 10) # Executes only once out of 10 times
695
+ import random # Ensure this is imported at the top of the file if not already
696
+ rand_int = random.randint(1, 20) # Executes only once out of 10 times
698
697
 
699
- # if rand_int == 1: # Executes only once out of 10 times
700
- # img.show()
698
+ if rand_int == 1: # Executes only once out of 10 times
699
+ img.save(os.path.join(get_temporary_directory(), 'before_crop.png'), 'PNG')
701
700
 
702
701
  if self.screen_capture_exclusions:
703
702
  img = img.convert("RGBA")
@@ -709,8 +708,9 @@ class ScreenshotClass:
709
708
  if self.custom_left:
710
709
  img = img.crop((self.custom_left, self.custom_top, self.custom_left + self.custom_width, self.custom_top + self.custom_height))
711
710
 
712
- # if rand_int == 1:
713
- # img.show()
711
+ if rand_int == 1:
712
+ img.save(os.path.join(get_temporary_directory(), 'after_crop.png'), 'PNG')
713
+ print(f'OCR images saved to {get_temporary_directory()} if debugging is needed, this is 1/20 chance')
714
714
 
715
715
  return img
716
716
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.8.30
3
+ Version: 2.8.33
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
@@ -1,11 +1,11 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=I98bvdxgZornaV1cnYux0-6AHnpEKkc4W56KCzOWC0s,14722
3
- GameSentenceMiner/config_gui.py,sha256=R7pUJDXCP7unGtBpuUjL0-8iWvY6LXRCYckHIrwkvF8,74207
2
+ GameSentenceMiner/anki.py,sha256=fu59gdyp1en_yKTK1WOVZX5lwGzGFKvhccXffgkoYlY,14190
3
+ GameSentenceMiner/config_gui.py,sha256=2klOj2DmHhmvtURp4JjhDJ1vn0hN-uWoUu1lS0xDl3s,74246
4
4
  GameSentenceMiner/configuration.py,sha256=ndnxuQbLfhMruHld-yK3UjWt1DcXlVhaLRZD8l6SJ0E,22562
5
5
  GameSentenceMiner/electron_config.py,sha256=dGcPYCISPehXubYSzsDuI2Gl092MYK0u3bTnkL9Jh1Y,9787
6
- GameSentenceMiner/ffmpeg.py,sha256=Gcx45ZwUTDjQ3fQkz1xm0Hcd4pT0X0n7AlADFlL-Srg,14509
6
+ GameSentenceMiner/ffmpeg.py,sha256=OXjus4JJ2LZKku5SJ1qN89rjZ3jIxbvvAHL-mhGL-5o,14513
7
7
  GameSentenceMiner/gametext.py,sha256=VogQDs-VQ4dorqy8uvoklweeS58r3Th_yP-zn36e0u4,5556
8
- GameSentenceMiner/gsm.py,sha256=iMVaAEEaMP8Vfzxiiz-2PR1y5bl1wde2DC-MwA0e3uw,26069
8
+ GameSentenceMiner/gsm.py,sha256=WmVhcC_CGjFmqV75NMMVm9hOiiv-ER4Lu5DUF-6IULo,26012
9
9
  GameSentenceMiner/model.py,sha256=JdnkT4VoPOXmOpRgFdvERZ09c9wLN6tUJxdrKlGZcqo,5305
10
10
  GameSentenceMiner/notification.py,sha256=FY39ChSRK0Y8TQ6lBGsLnpZUFPtFpSy2tweeXVoV7kc,2809
11
11
  GameSentenceMiner/obs.py,sha256=-tzVHejaGDXyERaDrRqrKmbgwT13oJKxTivGwfUij7Y,10284
@@ -22,16 +22,16 @@ GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
22
22
  GameSentenceMiner/downloader/download_tools.py,sha256=aRfpCqEmKUFRVsGipwY-7PhY6AeWiFJanW4ZCB9e2iE,8124
23
23
  GameSentenceMiner/downloader/oneocr_dl.py,sha256=o3ANp5IodEQoQ8GPcJdg9Y8JzA_lictwnebFPwwUZVk,10144
24
24
  GameSentenceMiner/ocr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=rQC6C8PKJXWoAvwCOYa363kodQQBwl1YNeYsD0bBbx4,1957
25
+ GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=-tw5l2wvv_sqUcGS0Y5X9LlXqmFxcCHcwZ76Q93T3I4,2127
26
26
  GameSentenceMiner/ocr/ocrconfig.py,sha256=_tY8mjnzHMJrLS8E5pHqYXZjMuLoGKYgJwdhYgN-ny4,6466
27
- GameSentenceMiner/ocr/owocr_area_selector.py,sha256=sryQd7D33i7E6c8gO7dnxLWtL6Nghgs7cvppK-xFxiE,47076
28
- GameSentenceMiner/ocr/owocr_helper.py,sha256=motXED_wX_CUljXp0pIaziw2xFBpz6gjokD2icDz02k,17358
27
+ GameSentenceMiner/ocr/owocr_area_selector.py,sha256=gHvhsgvYmIMKmkq0cDOLzBTnmBAvVyP9JKNlTZouJk8,47141
28
+ GameSentenceMiner/ocr/owocr_helper.py,sha256=_mRqQ8928ovdF5o_4qpK2DGWMmu3cGBYsmpgMtc0adU,17418
29
29
  GameSentenceMiner/owocr/owocr/__init__.py,sha256=opjBOyGGyEqZCE6YdZPnyt7nVfiwyELHsXA0jAsjm14,25
30
30
  GameSentenceMiner/owocr/owocr/__main__.py,sha256=XQaqZY99EKoCpU-gWQjNbTs7Kg17HvBVE7JY8LqIE0o,157
31
31
  GameSentenceMiner/owocr/owocr/config.py,sha256=qM7kISHdUhuygGXOxmgU6Ef2nwBShrZtdqu4InDCViE,8103
32
32
  GameSentenceMiner/owocr/owocr/lens_betterproto.py,sha256=oNoISsPilVVRBBPVDtb4-roJtAhp8ZAuFTci3TGXtMc,39141
33
33
  GameSentenceMiner/owocr/owocr/ocr.py,sha256=dPnDmtG-I24kcfxC3iudeRIVgGhLmiWMGyRiMANcYsA,41573
34
- GameSentenceMiner/owocr/owocr/run.py,sha256=oLXNYFZ4kHRfpSngGNSMEZa4zv6QmSW-x_bk9B1isOE,52096
34
+ GameSentenceMiner/owocr/owocr/run.py,sha256=ZC0sG-3mCyGgg8FPSto9Hd6-k-N18T1hBe-IgsbSBLM,52345
35
35
  GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py,sha256=Na6XStbQBtpQUSdbN3QhEswtKuU1JjReFk_K8t5ezQE,3395
36
36
  GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  GameSentenceMiner/vad/result.py,sha256=C08HsYH4qVjTRh_dvrWrskmXHJ950w0GWxPjGx_BfGY,275
@@ -52,9 +52,9 @@ GameSentenceMiner/web/static/web-app-manifest-512x512.png,sha256=wyqgCWCrLEUxSRX
52
52
  GameSentenceMiner/web/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  GameSentenceMiner/web/templates/text_replacements.html,sha256=tV5c8mCaWSt_vKuUpbdbLAzXZ3ATZeDvQ9PnnAfqY0M,8598
54
54
  GameSentenceMiner/web/templates/utility.html,sha256=NUp4Yjs6_j7YeqsM2rcF0LzwS6nXSBUWJDl-k2E8BbM,16270
55
- gamesentenceminer-2.8.30.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
56
- gamesentenceminer-2.8.30.dist-info/METADATA,sha256=qT-voNQ5NwqOcQtACk_VsApymhHJBiyLxIBWjnPdgnQ,7165
57
- gamesentenceminer-2.8.30.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
58
- gamesentenceminer-2.8.30.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
59
- gamesentenceminer-2.8.30.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
60
- gamesentenceminer-2.8.30.dist-info/RECORD,,
55
+ gamesentenceminer-2.8.33.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
56
+ gamesentenceminer-2.8.33.dist-info/METADATA,sha256=Tr9Brv6OO1-QMLV_nSZsR1DPy4-ZffwdVqWOX9OjZ9g,7165
57
+ gamesentenceminer-2.8.33.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
58
+ gamesentenceminer-2.8.33.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
59
+ gamesentenceminer-2.8.33.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
60
+ gamesentenceminer-2.8.33.dist-info/RECORD,,