|
|
@ -125,12 +125,13 @@ def modify_settings(data: dict, config_load, checks: dict):
|
|
|
|
|
|
|
|
|
|
|
|
# Delete background video
|
|
|
|
# Delete background video
|
|
|
|
def delete_background(key):
|
|
|
|
def delete_background(key):
|
|
|
|
# Read backgrounds.json
|
|
|
|
# Read background_videos.json
|
|
|
|
with open("utils/backgrounds.json", "r", encoding="utf-8") as backgrounds:
|
|
|
|
breakpoint()
|
|
|
|
|
|
|
|
with open("utils/background_videos.json", "r", encoding="utf-8") as backgrounds:
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
|
|
|
|
|
|
|
|
# Remove background from backgrounds.json
|
|
|
|
# Remove background from background_videos.json
|
|
|
|
with open("utils/backgrounds.json", "w", encoding="utf-8") as backgrounds:
|
|
|
|
with open("utils/background_videos.json", "w", encoding="utf-8") as backgrounds:
|
|
|
|
if data.pop(key, None):
|
|
|
|
if data.pop(key, None):
|
|
|
|
json.dump(data, backgrounds, ensure_ascii=False, indent=4)
|
|
|
|
json.dump(data, backgrounds, ensure_ascii=False, indent=4)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -139,7 +140,7 @@ def delete_background(key):
|
|
|
|
|
|
|
|
|
|
|
|
# Remove background video from ".config.template.toml"
|
|
|
|
# Remove background video from ".config.template.toml"
|
|
|
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
|
|
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
|
|
|
config["settings"]["background"]["background_choice"]["options"].remove(key)
|
|
|
|
config["settings"]["background"]["background_video"]["options"].remove(key)
|
|
|
|
|
|
|
|
|
|
|
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
|
|
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
|
|
|
toml_file.write(tomlkit.dumps(config))
|
|
|
|
toml_file.write(tomlkit.dumps(config))
|
|
|
@ -179,7 +180,7 @@ def add_background(youtube_uri, filename, citation, position):
|
|
|
|
filename = filename.replace(" ", "_")
|
|
|
|
filename = filename.replace(" ", "_")
|
|
|
|
|
|
|
|
|
|
|
|
# Check if background doesn't already exist
|
|
|
|
# Check if background doesn't already exist
|
|
|
|
with open("utils/backgrounds.json", "r", encoding="utf-8") as backgrounds:
|
|
|
|
with open("utils/background_videos.json", "r", encoding="utf-8") as backgrounds:
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
|
|
|
|
|
|
|
|
# Check if key isn't already taken
|
|
|
|
# Check if key isn't already taken
|
|
|
@ -193,7 +194,7 @@ def add_background(youtube_uri, filename, citation, position):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Add background video to json file
|
|
|
|
# Add background video to json file
|
|
|
|
with open("utils/backgrounds.json", "r+", encoding="utf-8") as backgrounds:
|
|
|
|
with open("utils/background_videos.json", "r+", encoding="utf-8") as backgrounds:
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
data = json.load(backgrounds)
|
|
|
|
|
|
|
|
|
|
|
|
data[filename] = [youtube_uri, filename + ".mp4", citation, position]
|
|
|
|
data[filename] = [youtube_uri, filename + ".mp4", citation, position]
|
|
|
@ -202,7 +203,7 @@ def add_background(youtube_uri, filename, citation, position):
|
|
|
|
|
|
|
|
|
|
|
|
# Add background video to ".config.template.toml"
|
|
|
|
# Add background video to ".config.template.toml"
|
|
|
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
|
|
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
|
|
|
config["settings"]["background"]["background_choice"]["options"].append(filename)
|
|
|
|
config["settings"]["background"]["background_video"]["options"].append(filename)
|
|
|
|
|
|
|
|
|
|
|
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
|
|
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
|
|
|
toml_file.write(tomlkit.dumps(config))
|
|
|
|
toml_file.write(tomlkit.dumps(config))
|
|
|
|