diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 58afa73c..18dfcdff 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -18,7 +18,7 @@ jobs: webhook_id: ${{ secrets.DEVELOP_WEBHOOK_ID }} webhook_token: ${{ secrets.DEVELOP_WEBHOOK_TOKEN }} title: Plex Meta Manager Develop Commits - message: "@Develop Notifications" + message: "<@&954835263731949623>" commits: "true" username: Metabot avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/develop/.github/pmm.png diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index af68b96f..1fb5298a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,7 +18,7 @@ jobs: webhook_id: ${{ secrets.NIGHTLY_WEBHOOK_ID }} webhook_token: ${{ secrets.NIGHTLY_WEBHOOK_TOKEN }} title: Nightly Commits - message: "@Nightly Notifications" + message: "<@&967002147520675840>" commits: "true" username: Metabot avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/nightly/.github/pmm.png diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 876922f5..a6548cd8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,6 @@ jobs: webhook_token: ${{ secrets.RELEASE_WEBHOOK_TOKEN }} release: true title: Plex Meta Manager Release VERSION - message: "@Master Notifications" + message: "<@&967002324646113290>" username: Metabot avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/master/.github/pmm.png \ No newline at end of file diff --git a/VERSION b/VERSION index 9f9ec2f3..d66c6f79 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5-develop29 +1.16.5-develop30 diff --git a/docs/metadata/dynamic.md b/docs/metadata/dynamic.md index e659d7f8..d617f81b 100644 --- a/docs/metadata/dynamic.md +++ b/docs/metadata/dynamic.md @@ -1628,15 +1628,17 @@ For example, when using `type: tmdb_collection` and you want to define a poster ```yaml templates: - optional: - - my_collection_poster - tmdb_collection_details: <> - collection_order: release - url_poster: <> + my_template: + optional: + - my_collection_poster + tmdb_collection_details: <> + collection_order: release + url_poster: <> dynamic_collections: TMDb Collections: # This name is the mapping name type: tmdb_collection remove_suffix: "Collection" + template: my_template template_variables: my_collection_poster: 119: https://www.themoviedb.org/t/p/original/oENY593nKRVL2PnxXsMtlh8izb4.jpg diff --git a/docs/metadata/overlay.md b/docs/metadata/overlay.md index 963a1b83..800a654d 100644 --- a/docs/metadata/overlay.md +++ b/docs/metadata/overlay.md @@ -59,7 +59,8 @@ You can specify the Overlay Name in 3 ways. | Attribute | Description | Required | |:----------|:--------------------------------------------------------------------------------------------------------------|:--------:| | `name` | Name of the overlay. Each overlay name should be unique. | ✅ | -| `url` | URL of Overlay Image Onlin. | ❌ | +| `file` | Local location of the Overlay Image. | ❌ | +| `url` | URL of Overlay Image Online. | ❌ | | `git` | Location in the [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs) of the Overlay Image. | ❌ | | `repo` | Location in the [Custom Repo](../config/settings.md#custom-repo) of the Overlay Image. | ❌ | | `group` | Name of the Grouping for this overlay. **`weight` is required when using `group`** | ❌ | diff --git a/modules/builder.py b/modules/builder.py index a6a9e384..b94d897b 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -271,6 +271,7 @@ class CollectionBuilder: self.suppress_overlays = [] self.overlay_group = None self.overlay_weight = None + self.overlay_path = None if self.overlay: if "overlay" in methods: logger.debug("") @@ -289,31 +290,33 @@ class CollectionBuilder: self.overlay_weight = pri else: raise Failed(f"{self.Type} Error: overlay group and overlay weight must be used together") - if "git" in data[methods["overlay"]] and data[methods["overlay"]]["git"]: - url = f"{util.github_base}{data[methods['overlay']]['git']}.png" - elif "repo" in data[methods["overlay"]] and data[methods["overlay"]]["repo"]: - url = f"{self.config.custom_repo}{data[methods['overlay']]['git']}.png" - elif "url" in data[methods["overlay"]] and data[methods["overlay"]]["url"]: - url = data[methods["overlay"]]["url"] - else: - url = None - if url: - response = self.config.get(url) + def get_and_save_image(image_url): + response = self.config.get(image_url) if response.status_code >= 400: - raise Failed(f"{self.Type} Error: Overlay Image not found at: {url}") + raise Failed(f"{self.Type} Error: Overlay Image not found at: {image_url}") if "Content-Type" not in response.headers or response.headers["Content-Type"] != "image/png": raise Failed(f"{self.Type} Error: Overlay Image not a png: {url}") if not os.path.exists(library.overlay_folder) or not os.path.isdir(library.overlay_folder): os.makedirs(library.overlay_folder, exist_ok=False) logger.info(f"Creating Overlay Folder found at: {library.overlay_folder}") - clean_name, _ = util.validate_filename(self.overlay) - overlay_path = os.path.join(library.overlay_folder, f"{clean_name}.png") - if os.path.exists(overlay_path): - os.remove(overlay_path) - with open(overlay_path, "wb") as handler: + clean_image_name, _ = util.validate_filename(self.overlay) + image_path = os.path.join(library.overlay_folder, f"{clean_image_name}.png") + if os.path.exists(image_path): + os.remove(image_path) + with open(image_path, "wb") as handler: handler.write(response.content) - while util.is_locked(overlay_path): + while util.is_locked(image_path): time.sleep(1) + return image_path + + if "file" in data[methods["overlay"]] and data[methods["overlay"]]["file"]: + self.overlay_path = data[methods["overlay"]]["file"] + elif "git" in data[methods["overlay"]] and data[methods["overlay"]]["git"]: + self.overlay_path = get_and_save_image(f"{util.github_base}{data[methods['overlay']]['git']}.png") + elif "repo" in data[methods["overlay"]] and data[methods["overlay"]]["repo"]: + self.overlay_path = get_and_save_image(f"{self.config.custom_repo}{data[methods['overlay']]['repo']}.png") + elif "url" in data[methods["overlay"]] and data[methods["overlay"]]["url"]: + self.overlay_path = get_and_save_image(data[methods["overlay"]]["url"]) else: self.overlay = str(data[methods["overlay"]]) else: @@ -328,10 +331,12 @@ class CollectionBuilder: except ValueError: logger.error(f"Overlay Error: failed to parse overlay blur name: {self.overlay} defaulting to blur(50)") self.overlay = "blur(50)" - - overlay_path = os.path.join(library.overlay_folder, f"{self.overlay}.png") - if not self.overlay.startswith("blur") and not os.path.exists(overlay_path): - raise Failed(f"{self.Type} Error: Overlay Image not found at: {overlay_path}") + else: + if not self.overlay_path: + clean_name, _ = util.validate_filename(self.overlay) + self.overlay_path = os.path.join(library.overlay_folder, f"{clean_name}.png") + if not os.path.exists(self.overlay_path): + raise Failed(f"{self.Type} Error: Overlay Image not found at: {self.overlay_path}") if "suppress_overlays" in methods: logger.debug("") diff --git a/modules/meta.py b/modules/meta.py index 1e38a598..f92b2257 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -92,6 +92,8 @@ class DataFile: else: raise Failed(f"File Error: File does not exist {os.path.abspath(file_path)}") data, _, _ = yaml.util.load_yaml_guess_indent(content) + if not data or not isinstance(data, dict): + raise Failed("YAML Error: File is empty") return data except yaml.scanner.ScannerError as ye: raise Failed(f"YAML Error: {util.tab_new_lines(ye)}") diff --git a/modules/overlays.py b/modules/overlays.py index bae0352f..54932158 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -38,7 +38,7 @@ class Overlays: if builder.overlay not in settings: settings[builder.overlay] = { "keys": [], "suppress": builder.suppress_overlays, "group": builder.overlay_group, - "weight": builder.overlay_weight, "updated": False, "image": None + "weight": builder.overlay_weight, "path": builder.overlay_path, "updated": False, "image": None } for method, value in builder.builders: @@ -78,14 +78,12 @@ class Overlays: if suppress_name in settings and rk in settings[suppress_name]["keys"]: settings[suppress_name]["keys"].remove(rk) if not overlay_name.startswith("blur"): - clean_name, _ = util.validate_filename(overlay_name) image_compare = None if self.config.Cache: _, image_compare, _ = self.config.Cache.query_image_map(overlay_name, f"{self.library.image_table_name}_overlays") - overlay_file = os.path.join(self.library.overlay_folder, f"{clean_name}.png") - overlay_size = os.stat(overlay_file).st_size + overlay_size = os.stat(settings[overlay_name]["path"]).st_size settings[overlay_name]["updated"] = not image_compare or str(overlay_size) != str(image_compare) - settings[overlay_name]["image"] = Image.open(overlay_file).convert("RGBA") + settings[overlay_name]["image"] = Image.open(settings[overlay_name]["path"]).convert("RGBA") if self.config.Cache: self.config.Cache.update_image_map(overlay_name, f"{self.library.image_table_name}_overlays", overlay_name, overlay_size)