| Added support for .mp3 and .flac loading...

This commit is contained in:
2025-05-04 23:56:14 +03:00
parent 660b41aef8
commit b1e18443ba
3 changed files with 83 additions and 81 deletions

View File

@ -2,20 +2,22 @@ import json
filepath = "my_data.json"
def write_data(filepath, data):
def write_data(filepath, data, debug=False):
try:
with open(filepath, 'w') as f:
json.dump(data, f, indent=4) # Use indent for pretty formatting
print(f"Data written to '{filepath}'")
if debug:
print(f"Data written to '{filepath}'")
except Exception as e:
print(f"Error writing to file: {e}")
def read_data(filepath):
def read_data(filepath, debug=False):
try:
with open(filepath, 'r') as f:
data = json.load(f)
print(f"Data read from '{filepath}'")
if debug:
print(f"Data read from '{filepath}'")
return data
except FileNotFoundError:
print(f"File not found: {filepath}")