From f458307674ce9011e4ab49df06e18f07e792d751 Mon Sep 17 00:00:00 2001 From: Yozora Date: Sun, 22 Dec 2024 09:44:19 +0000 Subject: [PATCH 01/10] [Config] Detect/Copy/Download config.yml from `config.yml.template` so users do not have to rename file. --- CHANGELOG | 7 ++++++- docs/config/overview.md | 9 ++++++--- kometa.py | 43 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 65b8c56eb..54a9c9989 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,11 +3,15 @@ Update pillow requirement to 11.0.0 Update psutil requirement to 6.1.0 Update setuptools requirement to 75.3.0 +# Important Changes +Python 3.8 is no longer supported. The minimum version of Python required is now 3.9. + # New Features Added the `character` search option to the `imdb_search` builder Added ability to use Show-level ratings at the season and episode level for Overlays if the original source does not provide ratings at the season or episode level. This is accomplished using (Special Text Variables)[https://kometa.wiki/en/latest/files/overlays/#special-text-variables] but is not yet available for the `Ratings` Defaults file. Add `show_unfiltered` setting to display items which make it through a filter Allow `sync_to_trakt_list` on episode-level collections +Logic added to Kometa to create `config.yml` if it does not exist from the `config.yml.template` file. If the template file cannot be found, Kometa will attempt to download it from GitHub. # Docs Added "getting started" page @@ -21,6 +25,7 @@ Fixes an issue where Prime Video overlays/collections would not be built when th Fixes an issue where Rotten Tomatoes Verified Hot wasn't working Updates `Alien vs Predator` and `X-Men` lists to new lists which include most recent releases Adds `style` template variable for Streaming and Chart defaults, allowing user to choose color or white logos for collection posters +Added `Paramount+ with Showtime` to both `Paramount+` and `Showtime` for Networks and Streaming, any existing weighting is unchanged. # Bug Fixes Fixed the `cast` search option for the `imdb_search` builder @@ -38,4 +43,4 @@ Fixes an issue causing IMDB collection to fail due to duplicate keys Removed Blog from the Navigation due to lack of time for updating/maintaining it Fixes #2354 by updating version of tmdbapi dependency Added Start Time, Finished and Run Time to Summary of run. -Fixed an issue where custom repositories would not work correctly if the URL did not end in a trailing `/` character. +Fixed an issue where custom repositories would not work correctly if the URL did not end in a trailing `/` character. \ No newline at end of file diff --git a/docs/config/overview.md b/docs/config/overview.md index bc9b374f8..7e361dc93 100644 --- a/docs/config/overview.md +++ b/docs/config/overview.md @@ -5,9 +5,11 @@ connection details needed to connect to Plex Media Server, Radarr, Sonarr, and o By default, and unless otherwise stated, Kometa looks for the configuration file at `/config/config.yml`. -A template Configuration File can be found in the +A template Configuration Template File can be found in the [GitHub Repo](https://github.com/Kometa-Team/Kometa/blob/master/config/config.yml.template). +If Kometa cannot find the `config.yml` at the default location, it will attempt to rename `config.yml.template` for the user. If the template file cannot be found, Kometa will attempt to download a copy from the GitHub repository in line with the user's current branch. If this also fails, the user will have to download the Configuration Template File from the above link and manually rename it to `config.yml` + This table outlines the third-party services that Kometa can make use of. Each service has specific requirements for setup that can be found by clicking the links within the table or in the sidebar. @@ -31,9 +33,10 @@ requirements for setup that can be found by clicking the links within the table | [`trakt`](trakt.md) | :fontawesome-solid-circle-xmark:{ .red } | | [`mal`](myanimelist.md) | :fontawesome-solid-circle-xmark:{ .red } | -## Configuration File Example +## Configuration Template File Example -This example outlines what a "standard" config.yml file might look like when in use. +The below in an extract of the `config.yml.template` and is the initial values that are set if you follow any of the +installation guides. ~~~yaml {% diff --git a/kometa.py b/kometa.py index 0e88a6681..615da6a45 100644 --- a/kometa.py +++ b/kometa.py @@ -1,4 +1,4 @@ -import argparse, os, platform, re, sys, time, uuid +import argparse, os, platform, re, sys, time, uuid, requests from collections import Counter from concurrent.futures import ProcessPoolExecutor from datetime import datetime @@ -194,8 +194,45 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): print(f"Config Error: config not found at {os.path.abspath(run_args['config'])}") sys.exit(0) elif not os.path.exists(os.path.join(default_dir, "config.yml")): - print(f"Config Error: config not found at {os.path.abspath(default_dir)}") - sys.exit(0) + 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() + 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 etc.") + sys.exit(1) + except Exception as e: + print(f"Error: Unable to copy the configuration template file from {template_path} to {config_path}. Details: {e}") + sys.exit(1) + else: + if git_branch: + github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{git_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"Error: No Configuration file (config.yml) found locally, 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.") + sys.exit(1) + except requests.RequestException as e: + print(f"Error: Failed to download the configuration template file (config.yml.template) from GitHub. Details: {e}") + sys.exit(1) + else: + print( + f"Configuration Error: The configuration file (config.yml) and its template (config.yml.template) are missing from {os.path.abspath(default_dir)}. " + "Additionally, the GitHub branch could not be determined. Please download the template file manually from the GitHub repository." + ) + sys.exit(0) + logger = MyLogger("Kometa", default_dir, run_args["width"], run_args["divider"][0], run_args["ignore-ghost"], run_args["tests"] or run_args["debug"], run_args["trace"], run_args["log-requests"]) From e95046a4d6dcf10db6019b9777fb83677c8268f0 Mon Sep 17 00:00:00 2001 From: Yozora Date: Sun, 22 Dec 2024 09:52:47 +0000 Subject: [PATCH 02/10] Update error wordings to be more consistent --- kometa.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kometa.py b/kometa.py index 615da6a45..eedbf6aa1 100644 --- a/kometa.py +++ b/kometa.py @@ -191,7 +191,7 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): if run_args["config"] and os.path.exists(run_args["config"]): 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: config not found at {os.path.abspath(run_args['config'])}") + print(f"Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}") sys.exit(0) elif not os.path.exists(os.path.join(default_dir, "config.yml")): template_path = os.path.join(default_dir, "config.yml.template") @@ -206,11 +206,11 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): print(f"Configuration file (config.yml) created at {config_path}. Please open this file and update it with your API keys etc.") sys.exit(1) except Exception as e: - print(f"Error: Unable to copy the configuration template file from {template_path} to {config_path}. Details: {e}") + print(f"Config Error: Unable to copy the Template file (config.yml.template) from {template_path} to {config_path}. Details: {e}") sys.exit(1) else: if git_branch: - github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{git_branch}/config/config.yml.template" + github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/bob/config/config.yml.template" try: response = requests.get(github_url, timeout=10) if response.status_code == 200: @@ -221,10 +221,10 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): 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"Error: No Configuration file (config.yml) found locally, 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.") + 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"Error: Failed to download the configuration template file (config.yml.template) from GitHub. Details: {e}") + print(f"Config Error: Failed to download the configuration template file (config.yml.template) from GitHub. Details: {e}") sys.exit(1) else: print( From aee770b22356a1cde9e94dc651b0862c3a5037b8 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 22 Dec 2024 09:53:43 +0000 Subject: [PATCH 03/10] create-config-file Part: 1 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index 8b1378917..d00491fd7 100644 --- a/PART +++ b/PART @@ -1 +1 @@ - +1 From 4a64caf1ff0e9eb73aa8d66459e528e047a09eca Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 22 Dec 2024 09:53:53 +0000 Subject: [PATCH 04/10] create-config-file Part: 2 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index d00491fd7..0cfbf0888 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -1 +2 From f6a9cc899d9893aa310c7205a6c93f533fb26b0c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 22 Dec 2024 09:54:25 +0000 Subject: [PATCH 05/10] create-config-file Part: 3 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index 0cfbf0888..00750edc0 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -2 +3 From 53e462fbdcd8b3e1c188a9c5702f11e1ed3c4d4c Mon Sep 17 00:00:00 2001 From: Yozora Date: Sun, 22 Dec 2024 17:31:52 +0000 Subject: [PATCH 06/10] fix branch detection and update wording --- kometa.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kometa.py b/kometa.py index eedbf6aa1..b86e5c308 100644 --- a/kometa.py +++ b/kometa.py @@ -203,14 +203,14 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): content = template_file.read() 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 etc.") + 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}") sys.exit(1) else: if git_branch: - github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/bob/config/config.yml.template" + github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{git_branch}/config/config.yml.template" try: response = requests.get(github_url, timeout=10) if response.status_code == 200: From cab7d4877de3a5877f9cb622bbb326add82c90ea Mon Sep 17 00:00:00 2001 From: Yozora Date: Mon, 6 Jan 2025 13:36:00 +0000 Subject: [PATCH 07/10] fallback github branch is master --- kometa.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/kometa.py b/kometa.py index b86e5c308..94e61b143 100644 --- a/kometa.py +++ b/kometa.py @@ -209,29 +209,23 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): print(f"Config Error: Unable to copy the Template file (config.yml.template) from {template_path} to {config_path}. Details: {e}") sys.exit(1) else: - if git_branch: - github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{git_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}") + 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"Configuration Error: The configuration file (config.yml) and its template (config.yml.template) are missing from {os.path.abspath(default_dir)}. " - "Additionally, the GitHub branch could not be determined. Please download the template file manually from the GitHub repository." - ) - sys.exit(0) + 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}") + sys.exit(1) logger = MyLogger("Kometa", default_dir, run_args["width"], run_args["divider"][0], run_args["ignore-ghost"], From 34902b98085ecc95bce69d6c39ae4f5ee77c08d5 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 6 Jan 2025 13:37:39 +0000 Subject: [PATCH 08/10] create-config-file Part: 4 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index 00750edc0..b8626c4cf 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -3 +4 From c8831dc3e8865f08fa8239d48512415ef15ce5fa Mon Sep 17 00:00:00 2001 From: YozoraXCII <96386153+YozoraXCII@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:38:02 +0000 Subject: [PATCH 09/10] Update CHANGELOG --- CHANGELOG | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4e1afcb2c..445da352e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,9 +12,6 @@ Update setuptools requirement to 75.6.0 # Important Changes Python 3.8 is no longer supported. The minimum version of Python required is now 3.9. -# Important Changes -Python 3.8 is no longer supported. The minimum version of Python required is now 3.9. - # New Features Added the `character` search option to the `imdb_search` builder Added ability to use Show-level ratings at the season and episode level for Overlays if the original source does not provide ratings at the season or episode level. This is accomplished using (Special Text Variables)[https://kometa.wiki/en/latest/files/overlays/#special-text-variables] but is not yet available for the `Ratings` Defaults file. @@ -56,4 +53,4 @@ Removed Blog from the Navigation due to lack of time for updating/maintaining it Fixes #2354 by updating version of tmdbapi dependency Added Start Time, Finished and Run Time to Summary of run. Fixed an issue where custom repositories would not work correctly if the URL did not end in a trailing `/` character. -Kometa will now check for `.yaml` extension in filenames if `.yml` is not found and vice-versa \ No newline at end of file +Kometa will now check for `.yaml` extension in filenames if `.yml` is not found and vice-versa From 81c0a3edb96e450e06e5b73acd4d9a07119e6d6c Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 6 Jan 2025 13:38:35 +0000 Subject: [PATCH 10/10] create-config-file Part: 5 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index b8626c4cf..7ed6ff82d 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -4 +5