proper closing, metadata file locations moved

This commit is contained in:
michalcourson
2026-03-01 13:48:31 -05:00
parent 801966e8d8
commit d37cd773f8
10 changed files with 483 additions and 40 deletions

View File

@ -75,7 +75,7 @@ def main():
app.register_blueprint(settings_bp)
print(f"Starting Flask server on port {settings.get_settings('http_port')}")
# app.run(host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=True)
socketio.run(app, host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=True, allow_unsafe_werkzeug=True)
socketio.run(app, host='127.0.0.1', port=settings.get_settings('http_port'), debug=False, use_reloader=False, allow_unsafe_werkzeug=True)

View File

@ -1,5 +1,6 @@
import os
import json
from platformdirs import user_data_dir
class MetaDataManager:
_instance = None
@ -12,12 +13,15 @@ class MetaDataManager:
def init(self):
self.socket = None
# read metadata file from executing directory
self.metadata_file = os.path.join(os.getcwd(), "metadata.json")
file_path = user_data_dir("ClipTrim")
os.makedirs(file_path, exist_ok=True)
print(file_path)
self.metadata_file = os.path.join(file_path, "metadata.json")
if os.path.exists(self.metadata_file):
with open(self.metadata_file, "r") as f:
self.collections = json.load(f)
else:
self.collections = {}
self.collections = []
if(collections := next((c for c in self.collections if c.get("name") == "Uncategorized"), None)) is None:
self.collections.append({"name": "Uncategorized", "id": 0, "clips": []})
self.save_metadata()

View File

@ -1,5 +1,7 @@
import os
import json
from platformdirs import user_data_dir
from audio_io import AudioIO
from windows_audio import WindowsAudioManager
@ -14,7 +16,9 @@ class SettingsManager:
def init(self):
# read settings file from executing directory
print("Initializing SettingsManager", os.getcwd())
self.settings_file = os.path.join(os.getcwd(), "settings.json")
file_path = user_data_dir("ClipTrim")
os.makedirs(file_path, exist_ok=True)
self.settings_file = os.path.join(file_path, "settings.json")
if os.path.exists(self.settings_file):
with open(self.settings_file, "r") as f:
self.settings = json.load(f)
@ -22,7 +26,7 @@ class SettingsManager:
self.settings = {
"input_device": None,
"output_device": None,
"save_path": os.path.join(os.getcwd(), "recordings"),
"save_path": os.path.join(file_path, "recordings"),
"recording_length": 15
}
audio_manager = WindowsAudioManager()