This commit is contained in:
IlyaShurupov 2024-07-10 20:54:40 +03:00
parent 22e19557d8
commit 59a3be1108
10 changed files with 227 additions and 204 deletions

View file

@ -1,31 +0,0 @@
import json
import os
data_dir = 'prefetched'
def get_data(name):
file_path = os.path.join(data_dir, f"{name}.json")
try:
with open(file_path, 'r') as file:
data = json.load(file)
return data
except FileNotFoundError:
return f"File {name}.json not found."
except json.JSONDecodeError:
return f"Error decoding JSON from {name}.json."
def save_data(data, name):
os.makedirs(data_dir, exist_ok=True)
file_path = os.path.join(data_dir, f"{name}.json")
with open(file_path, 'w') as file:
json.dump(data, file, indent=4)
return f"Data saved to {name}.json."
def get_artists_str(artists_pack):
track_artists = [artist['name'] for artist in artists_pack]
artists = " ".join(track_artists)
return artists