Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Jan 6, 2025
1 parent 8c4b483 commit a5d8941
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 39 deletions.
47 changes: 17 additions & 30 deletions kometa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import argparse, os, platform, re, sys, time, uuid, requests
import argparse, os, platform, re, sys, time, uuid
from collections import Counter
from concurrent.futures import ProcessPoolExecutor
from datetime import datetime
Expand Down Expand Up @@ -192,40 +192,27 @@ def get_env(env_str, default, arg_bool=False, arg_int=False):
default_dir = os.path.join(os.path.dirname(os.path.abspath(run_args["config"])))
elif run_args["config"] and not os.path.exists(run_args["config"]):
print(f"Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}")
sys.exit(0)
sys.exit(1)
elif not os.path.exists(os.path.join(default_dir, "config.yml")):
template_path = os.path.join(default_dir, "config.yml.template")
config_path = os.path.join(default_dir, "config.yml")

if os.path.exists(template_path):
try:
with open(template_path, 'r') as template_file:
content = template_file.read()
github_branch = git_branch if git_branch else "master"
github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{github_branch}/config/config.yml.template"
try:
response = requests.get(github_url, timeout=10)
if response.status_code == 200:
with open(config_path, 'w') as config_file:
config_file.write(content)
print(f"Configuration file (config.yml) created at {config_path}. Please open this file and update it with your API keys and other required settings.")
sys.exit(1)
except Exception as e:
print(f"Config Error: Unable to copy the Template file (config.yml.template) from {template_path} to {config_path}. Details: {e}")
config_file.write(response.text)
print(f"A Configuration file (config.yml) has been downloaded from GitHub and saved as {config_path}. "
f"Please update this file with your API keys and other required settings.")
sys.exit(1)
else:
github_branch = git_branch if git_branch else "master"
github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{github_branch}/config/config.yml.template"
try:
response = requests.get(github_url, timeout=10)
if response.status_code == 200:
with open(template_path, 'w') as template_file:
template_file.write(response.text)
with open(config_path, 'w') as config_file:
config_file.write(response.text)
print(f"A Configuration file (config.yml) has been downloaded from GitHub and saved as {config_path}. Please update this file with your API keys and other required settings.")
sys.exit(1)
else:
print(f"Config Error: No Configuration file (config.yml) or Template file (config.yml.template) found in the config path, and the template file(config.yml.template) could not be downloaded from GitHub. Please visit the GitHub repository to manually download the config.yml.template file and place it in {template_path} prior to running Kometa again.")
sys.exit(1)
except requests.RequestException as e:
print(f"Config Error: Failed to download the configuration template file (config.yml.template) from GitHub. Details: {e}")
else:
print(f"Config Error: No Configuration file (config.yml) found in the config path and it could not be "
f"downloaded from GitHub. Please visit the GitHub repository to manually download the "
f"config.yml.template file and place it in {config_path} prior to running Kometa again.")
sys.exit(1)
except requests.RequestException as e:
print(f"Config Error: Failed to download the configuration template file (config.yml.template) from GitHub. Details: {e}")
sys.exit(1)


logger = MyLogger("Kometa", default_dir, run_args["width"], run_args["divider"][0], run_args["ignore-ghost"],
Expand Down
15 changes: 7 additions & 8 deletions modules/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,14 @@ def load_file(self, file_type, file_path, overlay=False, translation=False, imag
content_path = os.path.abspath(os.path.join(file_path, "default.yml") if translation else file_path)
dir_path = file_path
if not os.path.exists(content_path):
if content_path.endswith(".yml") and os.path.exists(content_path[:-4] + ".yaml"):
content_path = content_path[:-4] + ".yaml"
elif content_path.endswith(".yaml") and os.path.exists(content_path[:-5] + ".yml"):
content_path = content_path[:-5] + ".yml"
if content_path.endswith(".yml") and os.path.exists(f"{content_path[:-4]}.yaml"):
content_path = f"{content_path[:-4]}.yaml"
elif content_path.endswith(".yaml") and os.path.exists(f"{content_path[:-5]}.yml"):
content_path = f"{content_path[:-5]}.yml"
elif file_type == "Default":
raise Failed(f"File Error: Default does not exist {file_path}")
else:
if file_type == "Default":
raise Failed(f"File Error: Default does not exist {file_path}")
else:
raise Failed(f"File Error: File does not exist {content_path}")
raise Failed(f"File Error: File does not exist {content_path}")
yaml = self.config.Requests.file_yaml(content_path, check_empty=True)
if not translation:
logger.debug(f"File Loaded From: {content_path}")
Expand Down
2 changes: 1 addition & 1 deletion modules/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def mal_obj():
if self.library.mass_background_update:
source = self.library.mass_background_update["source"]
ignore_locked = self.library.mass_background_update["ignore_locked"]
ignore_overlays = self.library.mass_poster_update["ignore_overlays"]
ignore_overlays = self.library.mass_background_update["ignore_overlays"]
art_locked = any(f.name == "art" and f.locked for f in item.fields)

if source in ["unlock", "lock"]:
Expand Down

0 comments on commit a5d8941

Please sign in to comment.