From abe6e4c8412cc3b72d58d77a6a7b4905727b2d97 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 30 Apr 2024 09:54:20 -0400 Subject: [PATCH] [8] add `overlay_filetype` and `overlay_quality` settings --- CHANGELOG | 17 ++------ VERSION | 2 +- config/config.yml.template | 2 + docs/config/settings.md | 65 +++++++++++++++++++++++++----- docs/defaults/chart/myanimelist.md | 2 +- json-schema/config-schema.json | 10 +++++ json-schema/prototype_config.yml | 2 + modules/config.py | 17 ++++++-- modules/library.py | 2 + modules/overlays.py | 7 +++- 10 files changed, 96 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3a811623..e0c55fd0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,26 +1,17 @@ -# Plex Meta Manager is now rebranded as Kometa! - # Requirements Update (requirements will need to be reinstalled) -Updated arrapi requirement to 1.4.13 -Updated PlexAPI requirement to 4.15.12 -Updated setuptools requirement to 69.5.1 -Updated tmdbapis requirement to 1.2.16 # Removed Features # New Features -Add Page Topics Options to `imdb_search` -Add `lxml` Docker Version using an old lxml version that supports more cpus +Added `overlay_filetype` and `overlay_quality` settings to control the filetype and quality of overlay images. # Updates -Add `use_all` template variable to default collections, which allows all collections to be disabled with one variable. -Let conditional `.not` and `.exists` work with default variables - +Added `starting_only` template variable to the `mal` Collection Default. # Defaults # Bug Fixes -Fixes #1965 `download_url_assets` was causing `url_background` to upload as a poster -Fixes #1969 Ignore validating TPDb links +Catch bad ID data from Plex +Fixes `- git` file calls Various other Minor Fixes diff --git a/VERSION b/VERSION index ef0092c2..d164aac3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0-develop7 +2.0.0-develop8 diff --git a/config/config.yml.template b/config/config.yml.template index 780c294d..a468313b 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -74,6 +74,8 @@ settings: playlist_report: false verify_ssl: true custom_repo: + overlay_filetype: jpg + overlay_quality: 75 webhooks: # Can be individually specified per library as well error: version: diff --git a/docs/config/settings.md b/docs/config/settings.md index b704c9c4..061839ce 100644 --- a/docs/config/settings.md +++ b/docs/config/settings.md @@ -935,6 +935,31 @@ The available setting attributes which can be set at each level are outlined bel - metadata ``` +??? blank "`verify_ssl` - Turn SSL Verification on or off." + +
Turn SSL Verification on or off. + + ???+ note + + set to false if your log file shows any errors similar to "SSL: CERTIFICATE_VERIFY_FAILED" + +
+ + **Attribute:** `verify_ssl` + + **Levels with this Attribute:** Global + + **Accepted Values:** `true` or `false` + + **Default Value:** `true` + + ???+ example "Example" + + ```yaml + settings: + verify_ssl: false + ``` + ??? blank "`custom_repo` - Used to set up the custom `repo` [file block type](files.md#location-types-and-paths)."
Specify where the `repo` attribute's base is when defining `collection_files`, @@ -962,29 +987,51 @@ The available setting attributes which can be set at each level are outlined bel custom_repo: https://github.com/Kometa-Team/Community-Configs/tree/master/meisnate12 ``` -??? blank "`verify_ssl` - Turn SSL Verification on or off." +??? blank "`overlay_filetype` - Used to control the filetype used with overlay images." -
Turn SSL Verification on or off. +
Used to control the filetype used with overlay images. + +
- ???+ note + **Attribute:** `overlay_filetype` + + **Levels with this Attribute:** Global/Library - set to false if your log file shows any errors similar to "SSL: CERTIFICATE_VERIFY_FAILED" + **Accepted Values:** + + + + +
`jpg`Use JPG files for saving Overlays
`png`Use PNG files for saving Overlays
+ + **Default Value:** `jpg` + + ???+ example "Example" + + ```yaml + settings: + overlay_filetype: png + ``` + +??? blank "`overlay_quality` - Used to control the JPG quality used with overlay images." + +
Used to control the JPG quality used with overlay images.
- **Attribute:** `verify_ssl` + **Attribute:** `overlay_quality` - **Levels with this Attribute:** Global + **Levels with this Attribute:** Global/Library - **Accepted Values:** `true` or `false` + **Accepted Values:** Any Integer 1-100 - **Default Value:** `true` + **Default Value:** `75` ???+ example "Example" ```yaml settings: - verify_ssl: false + overlay_quality: 95 ``` ## Default Values diff --git a/docs/defaults/chart/myanimelist.md b/docs/defaults/chart/myanimelist.md index f691e468..0a8c23b8 100644 --- a/docs/defaults/chart/myanimelist.md +++ b/docs/defaults/chart/myanimelist.md @@ -53,7 +53,7 @@ work. Any value not specified will use its default value if it has one if not it | `limit` | **Description:** Changes the Builder Limit for all collections in a Defaults file.
**Default:** `100`
**Values:** Number greater than 0 | | `limit_<>`1 | **Description:** Changes the Builder Limit of the specified key's collection.
**Default:** `limit`
**Values:** Number greater than 0 | | `sync_mode` | **Description:** Changes the Sync Mode for all collections in a Defaults file.
**Default:** `sync`
**Values:**
`sync`Add and Remove Items based on Builders
`append`Only Add Items based on Builders
| - | `starting_only` | **Description** Changes the season collection to only use anime listed under the new section on [MAL Seasons](https://myanimelist.net/anime/season/)
**Default:** `False`
**Values:** `True` or `False` | + | `starting_only` | **Description:** Changes the season collection to only use anime listed under the new section on [MAL Seasons](https://myanimelist.net/anime/season/)
**Default:** `False`
**Values:** `True` or `False` | | `sync_mode_<>`1 | **Description:** Changes the Sync Mode of the specified key's collection.
**Default:** `sync_mode`
**Values:**
`sync`Add and Remove Items based on Builders
`append`Only Add Items based on Builders
| | `collection_order` | **Description:** Changes the Collection Order for all collections in a Defaults file.
**Default:** `custom`
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom`Order Collection Via the Builder Order
[Any `plex_search` Sort Option](../../files/builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| | `collection_order_<>`1 | **Description:** Changes the Collection Order of the specified key's collection.
**Default:** `collection_order`
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom`Order Collection Via the Builder Order
[Any `plex_search` Sort Option](../../files/builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| diff --git a/json-schema/config-schema.json b/json-schema/config-schema.json index 69c5894e..c39d4aac 100644 --- a/json-schema/config-schema.json +++ b/json-schema/config-schema.json @@ -895,6 +895,16 @@ "type": "string" } ] + }, + "overlay_filetype": { + "description": "Used to control the filetype used with overlay images.", + "enum": ["jpg", "png"] + }, + "overlay_quality": { + "description": "Used to control the JPG quality used with overlay images.", + "type": "integer", + "minimum": 1, + "maximum": 100 } }, "required": [ diff --git a/json-schema/prototype_config.yml b/json-schema/prototype_config.yml index 675cdbc1..49d706ce 100644 --- a/json-schema/prototype_config.yml +++ b/json-schema/prototype_config.yml @@ -440,6 +440,8 @@ settings: playlist_report: false verify_ssl: true custom_repo: + overlay_filetype: jpg + overlay_quality: jpg webhooks: # Can be individually specified per library as well error: version: diff --git a/modules/config.py b/modules/config.py index 4702a3f6..c1806f39 100644 --- a/modules/config.py +++ b/modules/config.py @@ -41,6 +41,10 @@ run_order_options = { "operations": "Represents Operations Updates" } sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"} +filetype_list = { + "jpg": "Use JPG files for saving Overlays", + "png": "Use PNG files for saving Overlays" +} imdb_label_options = { "remove": "Remove All IMDb Parental Labels", "none": "Add IMDb Parental Labels for None, Mild, Moderate, or Severe", @@ -340,7 +344,7 @@ class ConfigFile: if self.secrets: check_next(self.data) - def check_for_attribute(data, attribute, parent=None, test_list=None, default=None, do_print=True, default_is_none=False, req_default=False, var_type="str", throw=False, save=True, int_min=0): + def check_for_attribute(data, attribute, parent=None, test_list=None, default=None, do_print=True, default_is_none=False, req_default=False, var_type="str", throw=False, save=True, int_min=0, int_max=None): endline = "" if parent is not None: if data and parent in data: @@ -373,9 +377,10 @@ class ConfigFile: if isinstance(data[attribute], bool): return data[attribute] else: message = f"{text} must be either true or false" elif var_type == "int": - if isinstance(data[attribute], bool): message = f"{text} must an integer >= {int_min}" - elif isinstance(data[attribute], int) and data[attribute] >= int_min: return data[attribute] - else: message = f"{text} must an integer >= {int_min}" + if isinstance(data[attribute], int) and data[attribute] >= int_min and (not int_max or data[attribute] <= int_max): + return data[attribute] + else: + message = f"{text} must an integer greater than or equal to {int_min}{f' and less than or equal to {int_max}'}" elif var_type == "path": if os.path.exists(os.path.abspath(data[attribute])): return data[attribute] else: message = f"Path {os.path.abspath(data[attribute])} does not exist" @@ -472,6 +477,8 @@ class ConfigFile: "playlist_report": check_for_attribute(self.data, "playlist_report", parent="settings", var_type="bool", default=True), "verify_ssl": check_for_attribute(self.data, "verify_ssl", parent="settings", var_type="bool", default=True), "custom_repo": check_for_attribute(self.data, "custom_repo", parent="settings", default_is_none=True), + "overlay_filetype": check_for_attribute(self.data, "overlay_filetype", parent="settings", test_list=filetype_list, default="jpg"), + "overlay_quality": check_for_attribute(self.data, "overlay_quality", parent="settings", var_type="int", default_is_none=True, int_min=1, int_max=100), "assets_for_all": check_for_attribute(self.data, "assets_for_all", parent="settings", var_type="bool", default=False, save=False, do_print=False) } self.custom_repo = None @@ -850,6 +857,8 @@ class ConfigFile: params["ignore_ids"].extend([i for i in self.general["ignore_ids"] if i not in params["ignore_ids"]]) params["ignore_imdb_ids"] = check_for_attribute(lib, "ignore_imdb_ids", parent="settings", var_type="lower_list", default_is_none=True, do_print=False, save=False) params["ignore_imdb_ids"].extend([i for i in self.general["ignore_imdb_ids"] if i not in params["ignore_imdb_ids"]]) + params["overlay_filetype"] = check_for_attribute(lib, "overlay_filetype", parent="settings", test_list=filetype_list, default=self.general["overlay_filetype"], do_print=False, save=False), + params["overlay_quality"] = check_for_attribute(lib, "overlay_quality", parent="settings", var_type="int", default=self.general["delete_not_scheduled"], default_is_none=True, int_min=1, int_max=100, do_print=False, save=False), params["changes_webhooks"] = check_for_attribute(lib, "changes", parent="webhooks", var_type="list", default=self.webhooks["changes"], do_print=False, save=False, default_is_none=True) params["report_path"] = None if lib and "report_path" in lib and lib["report_path"]: diff --git a/modules/library.py b/modules/library.py index bc07266d..0b4774b5 100644 --- a/modules/library.py +++ b/modules/library.py @@ -81,6 +81,8 @@ class Library(ABC): self.only_filter_missing = params["only_filter_missing"] self.ignore_ids = params["ignore_ids"] self.ignore_imdb_ids = params["ignore_imdb_ids"] + self.overlay_quality = params["overlay_quality"] + self.overlay_filetype = params["overlay_filetype"] self.assets_for_all = params["assets_for_all"] self.assets_for_all_collections = False self.delete_collections = params["delete_collections"] diff --git a/modules/overlays.py b/modules/overlays.py index 2260493a..cb42c048 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -507,8 +507,11 @@ class Overlays: else: overlay_box = current_overlay.get_coordinates((canvas_width, canvas_height), box=current_overlay.image.size, new_cords=cord) new_poster.paste(current_overlay.image, overlay_box, current_overlay.image) - temp = os.path.join(self.library.overlay_folder, "temp.jpg") - new_poster.save(temp, exif=exif_tags) + temp = os.path.join(self.library.overlay_folder, f"temp.{self.library.overlay_filetype}") + if self.library.overlay_filetype == "jpg" and self.library.overlay_quality: + new_poster.save(temp, exif=exif_tags, quality=self.library.overlay_quality) + else: + new_poster.save(temp, exif=exif_tags) self.library.upload_poster(item, temp) self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False) poster_compare = poster.compare if poster else item.thumb