From f33b583aec478e687eb0a0455db4e3b24c0a4d56 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 30 Apr 2025 15:21:24 +0200 Subject: [PATCH] feat(voice_to_text_tray): enhance journal creation with error handling and timestamp formatting Signed-off-by: Max P. --- src/pyvtt/voice_to_text_tray.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pyvtt/voice_to_text_tray.py b/src/pyvtt/voice_to_text_tray.py index f2bf2ca..c86a042 100755 --- a/src/pyvtt/voice_to_text_tray.py +++ b/src/pyvtt/voice_to_text_tray.py @@ -100,9 +100,17 @@ class WhisperWorker(QThread): today = datetime.date.today().strftime("%Y.%m.%d") journal_path = os.path.join(CONFIGURATION["journal_path"], f"{today} - {CURRENT_PRESET['journal_name']}.md") now = datetime.datetime.now().strftime("%H:%M") + if not os.path.exists(journal_path): + try: + with open(journal_path, "w") as f: + f.write(f"# {CURRENT_PRESET['journal_name']} - {today}\n\n") + except Exception as e: + print(f"Journal Erstellungsfehler: {e}") + notify("Fehler", "Ein Fehler beim Erstellen des Journals ist aufgetreten!") + return try: with open(journal_path, "a") as f: - f.write(f"## {now}\n") + f.write(f"## {now} Uhr\n") f.write(f"{formatted_result}\n\n") except Exception as e: print(f"Journal Fehler: {e}")