GameSentenceMiner 2.19.13__py3-none-any.whl → 2.19.15__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/gsm.py CHANGED
@@ -12,8 +12,14 @@ def handle_error_in_initialization(e):
12
12
  logger.info("Exiting due to initialization error.")
13
13
  sys.exit(1)
14
14
 
15
+ Icon = None
15
16
 
16
17
  try:
18
+ import GameSentenceMiner.util.configuration
19
+ from GameSentenceMiner.util.configuration import logger, gsm_state, get_config, anki_results, AnkiUpdateResult, \
20
+ get_temporary_directory, get_log_path, get_master_config, switch_profile_and_save, get_app_directory, gsm_status, \
21
+ is_windows, is_linux, get_ffmpeg_path, is_mac
22
+
17
23
  import asyncio
18
24
  import os
19
25
  import shutil
@@ -33,16 +39,16 @@ try:
33
39
  import keyboard
34
40
  import ttkbootstrap as ttk
35
41
  from PIL import Image
36
- from pystray import Icon, Menu, MenuItem
42
+ try:
43
+ pass
44
+ # from pystray import Icon, Menu, MenuItem
45
+ except Exception:
46
+ logger.warning("pystray not installed correctly, tray icon will not work.")
37
47
  from watchdog.events import FileSystemEventHandler
38
48
  from watchdog.observers import Observer
39
49
  import psutil
40
50
 
41
51
  start_time = time.time()
42
- import GameSentenceMiner.util.configuration
43
- from GameSentenceMiner.util.configuration import logger, gsm_state, get_config, anki_results, AnkiUpdateResult, \
44
- get_temporary_directory, get_log_path, get_master_config, switch_profile_and_save, get_app_directory, gsm_status, \
45
- is_windows, is_linux, get_ffmpeg_path
46
52
 
47
53
  logger.debug(f"[Import] configuration: {time.time() - start_time:.3f}s")
48
54
 
@@ -443,9 +449,15 @@ class GSMTray(threading.Thread):
443
449
  self.icon = None
444
450
 
445
451
  def run(self):
452
+ if not Icon:
453
+ logger.warning("Tray icon functionality is not available.")
454
+ return
446
455
  self.run_tray()
447
456
 
448
457
  def run_tray(self):
458
+ if not Icon:
459
+ logger.warning("Tray icon functionality is not available.")
460
+ return
449
461
  def run_anki_confirmation_window():
450
462
  settings_window.show_anki_confirmation_dialog(expression="こんにちは",
451
463
  sentence="こんにちは、世界!元気ですか?",
@@ -475,6 +487,8 @@ class GSMTray(threading.Thread):
475
487
 
476
488
  def update_icon(self, profile=None):
477
489
  global menu, icon
490
+ if not self.icon:
491
+ return
478
492
  # Recreate the menu with the updated button text
479
493
  profile_menu = Menu(
480
494
  *[MenuItem(("Active: " if profile == get_master_config().current_profile else "") + profile, self.switch_profile) for
@@ -496,6 +510,8 @@ class GSMTray(threading.Thread):
496
510
  self.icon.update_menu()
497
511
 
498
512
  def switch_profile(self, icon, item):
513
+ if not self.icon:
514
+ return
499
515
  if "Active:" in item.text:
500
516
  logger.error("You cannot switch to the currently active profile!")
501
517
  return
@@ -509,11 +525,15 @@ class GSMTray(threading.Thread):
509
525
  send_restart_signal()
510
526
 
511
527
  def play_pause(self, icon, item):
528
+ if not self.icon:
529
+ return
512
530
  global obs_paused, menu
513
531
  obs.toggle_replay_buffer()
514
532
  self.update_icon()
515
533
 
516
534
  def stop(self):
535
+ if not self.icon:
536
+ return
517
537
  if self.icon:
518
538
  self.icon.stop()
519
539
 
@@ -681,6 +701,9 @@ def initialize(reloading=False):
681
701
  if shutil.which("ffmpeg") is None:
682
702
  os.environ["PATH"] += os.pathsep + \
683
703
  os.path.dirname(get_ffmpeg_path())
704
+ if is_mac():
705
+ if shutil.which("ffmpeg") is None:
706
+ os.environ["PATH"] += os.pathsep + "/opt/homebrew/bin"
684
707
  if get_config().obs.open_obs:
685
708
  obs_process = obs.start_obs()
686
709
  # obs.connect_to_obs(start_replay=True)
@@ -861,13 +884,15 @@ async def async_main(reloading=False):
861
884
  try:
862
885
  if get_config().general.open_config_on_startup:
863
886
  root.after(50, settings_window.show)
864
- root.after(50, gsm_tray.start)
887
+ if Icon:
888
+ root.after(50, gsm_tray.start)
865
889
  # root.after(100, settings_window.show_anki_confirmation_dialog(expression="こんにちは",
866
890
  # sentence="こんにちは、世界!元気ですか?",
867
891
  # screenshot_path="test_image.png",
868
892
  # audio_path="C:/path/to/my/audio.mp3",
869
893
  # translation="Hello world! How are you?"))
870
- settings_window.add_save_hook(gsm_tray.update_icon)
894
+ if Icon:
895
+ settings_window.add_save_hook(gsm_tray.update_icon)
871
896
  settings_window.add_save_hook(on_config_changed)
872
897
  settings_window.on_exit = exit_program
873
898
  root.mainloop()
@@ -89,6 +89,9 @@ def is_linux():
89
89
  def is_windows():
90
90
  return platform == 'win32'
91
91
 
92
+ def is_mac():
93
+ return platform == 'darwin'
94
+
92
95
 
93
96
  class Locale(Enum):
94
97
  English = 'en_us'
@@ -1394,10 +1397,22 @@ is_beangate = os.path.exists("C:/Users/Beangate")
1394
1397
 
1395
1398
 
1396
1399
  def get_ffmpeg_path():
1397
- return os.path.join(get_app_directory(), "ffmpeg", "ffmpeg.exe") if is_windows() else "ffmpeg"
1400
+ path = os.path.join(get_app_directory(), "ffmpeg", "ffmpeg.exe") if is_windows() else "ffmpeg"
1401
+ if shutil.which(path) is not None:
1402
+ return path
1403
+ elif is_mac():
1404
+ if shutil.which("/opt/homebrew/bin/ffmpeg") is not None:
1405
+ return "/opt/homebrew/bin/ffmpeg"
1406
+ return path
1398
1407
 
1399
1408
  def get_ffprobe_path():
1400
- return os.path.join(get_app_directory(), "ffmpeg", "ffprobe.exe") if is_windows() else "ffprobe"
1409
+ path = os.path.join(get_app_directory(), "ffmpeg", "ffprobe.exe") if is_windows() else "ffprobe"
1410
+ if shutil.which(path) is not None:
1411
+ return path
1412
+ elif is_mac():
1413
+ if shutil.which("/opt/homebrew/bin/ffprobe") is not None:
1414
+ return "/opt/homebrew/bin/ffprobe"
1415
+ return path
1401
1416
 
1402
1417
  ffmpeg_base_command_list = [get_ffmpeg_path(), "-hide_banner", "-loglevel", "error", '-nostdin']
1403
1418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.19.13
3
+ Version: 2.19.15
4
4
  Summary: A tool for mining sentences from games. Update: Dependencies, replay buffer based line searching, and bug fixes.
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -1,7 +1,7 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  GameSentenceMiner/anki.py,sha256=SvmkL-7AqMKtCWfgwyxALvEHBOoxmQabi_uSYahf5nU,29982
3
3
  GameSentenceMiner/gametext.py,sha256=4PPm7QSWDmvsyooVjFANkd1Vnoy5ixbGRMHfYfhwGs0,13320
4
- GameSentenceMiner/gsm.py,sha256=N4m3tqesHkwkgLeOAlBvzwCYiy2INNZ85maZWCdglUM,36186
4
+ GameSentenceMiner/gsm.py,sha256=3jmcW5NZ8VDsGgwr_RaWEcTtd_HdBSA-smdtAeGbZlo,36938
5
5
  GameSentenceMiner/obs.py,sha256=UB4_OJ-vZQbHyuupB8JmwhSFdYyQX_5f5TpRXU1D7Kk,43300
6
6
  GameSentenceMiner/vad.py,sha256=iMSsoUZ7-aNoWKzDKfOHdB3Zk5U2hV7x5hqTny6rj08,21501
7
7
  GameSentenceMiner/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -42,7 +42,7 @@ GameSentenceMiner/ui/furigana_filter_preview.py,sha256=DAT2-j6vSDHr9ufk6PiaLikEs
42
42
  GameSentenceMiner/ui/screenshot_selector.py,sha256=MnR1MZWRUeHXCFTHc5ACK3WS08f9MUK5fJ6IQEGdCEY,9127
43
43
  GameSentenceMiner/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  GameSentenceMiner/util/audio_player.py,sha256=-yFsf0qoTSS1ga5rCmEJZJGUSJzXCvfZHY3t0NxycDk,7896
45
- GameSentenceMiner/util/configuration.py,sha256=X6AFueDXi-HabDCGf8u44Z1rPO8XR6Wal3SvGz7hcbI,48806
45
+ GameSentenceMiner/util/configuration.py,sha256=lmk0CEGbu-wFU40O-1X8MvLZNNpNT3g1apghgOjidCM,49265
46
46
  GameSentenceMiner/util/db.py,sha256=iCHUzlgOJgNjQ5-oDa7gnDWmzdlEryOzbXfn9ToQPfY,33034
47
47
  GameSentenceMiner/util/electron_config.py,sha256=KfeJToeFFVw0IR5MKa-gBzpzaGrU-lyJbR9z-sDEHYU,8767
48
48
  GameSentenceMiner/util/ffmpeg.py,sha256=KZhoVVCGnlPIoVJ83XVQmjHDnzO4WefZRoLyceS6pEE,40100
@@ -135,9 +135,9 @@ GameSentenceMiner/web/templates/components/kanji_grid/thousand_character_classic
135
135
  GameSentenceMiner/web/templates/components/kanji_grid/wanikani_levels.json,sha256=8wjnnaYQqmho6t5tMxrIAc03512A2tYhQh5dfsQnfAM,11372
136
136
  GameSentenceMiner/web/templates/components/kanji_grid/words_hk_frequency_list.json,sha256=wRkqZNPzz6DT9OTPHpXwfqW96Qb96stCQNNgOL-ZdKk,17535
137
137
  GameSentenceMiner/wip/__init___.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
- gamesentenceminer-2.19.13.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
139
- gamesentenceminer-2.19.13.dist-info/METADATA,sha256=IfL5PQ5pFr7zYNl2dNtx3F7S0cG5U0jCdq7A4oNtL04,8187
140
- gamesentenceminer-2.19.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
141
- gamesentenceminer-2.19.13.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
142
- gamesentenceminer-2.19.13.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
143
- gamesentenceminer-2.19.13.dist-info/RECORD,,
138
+ gamesentenceminer-2.19.15.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
139
+ gamesentenceminer-2.19.15.dist-info/METADATA,sha256=94chKcRdmWWf6N4BGCli2xQNrNFOLpEHLuGTBvtX_bM,8187
140
+ gamesentenceminer-2.19.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
141
+ gamesentenceminer-2.19.15.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
142
+ gamesentenceminer-2.19.15.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
143
+ gamesentenceminer-2.19.15.dist-info/RECORD,,