From f7d7de36f9c77697d029ee7a9f6f35563dea72d9 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 20 Apr 2022 01:27:00 -0400 Subject: [PATCH] [10] Add blur overlay --- .github/ISSUE_TEMPLATE/1.bug_report.yml | 4 +-- VERSION | 2 +- docs/metadata/builders/smart.md | 2 ++ docs/metadata/metadata.md | 2 +- docs/metadata/overlay.md | 14 +++++++++++ modules/builder.py | 2 +- modules/overlays.py | 33 +++++++++++++++---------- 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1.bug_report.yml b/.github/ISSUE_TEMPLATE/1.bug_report.yml index 43c700e8..6d2f34d9 100644 --- a/.github/ISSUE_TEMPLATE/1.bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1.bug_report.yml @@ -38,9 +38,9 @@ body: - type: textarea id: config attributes: - label: Relevant Collection/Playlist Definition + label: Relevant Collection/Overlay/Playlist Definition description: > - If you issue is happening with a specific collection/playlist please paste your definition here + If you issue is happening with a specific collection/overlay/playlist please paste your definition here This will be automatically formatted into code, so no need for backticks. render: yml - type: input diff --git a/VERSION b/VERSION index 18e6ad49..6e832de6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5-develop9 +1.16.5-develop10 diff --git a/docs/metadata/builders/smart.md b/docs/metadata/builders/smart.md index a7d19577..4b086c27 100644 --- a/docs/metadata/builders/smart.md +++ b/docs/metadata/builders/smart.md @@ -2,6 +2,8 @@ Smart Builders allow Plex Meta Manager to create Smart Collections in two different ways. +** Smart Builders do not currently work with Playlists ** + ## Smart Label A Smart Label Collection is a smart collection that grabs every item with a specific label generated by the program. That label is added to all the items the Collection Builders find instead of being added to a normal collection. diff --git a/docs/metadata/metadata.md b/docs/metadata/metadata.md index 8d05c4fd..7d56be2e 100644 --- a/docs/metadata/metadata.md +++ b/docs/metadata/metadata.md @@ -47,7 +47,7 @@ There are three types of attributes that can be utilized within a collection: Builders use third-party services to source items to be added to the collection. Multiple builders can be used in the same collection from a variety of sources listed below. * [Plex Builders](builders/plex) -* [Smart Builders](builders/smart) +* [Smart Builders](builders/smart) (Collections Only) * [TMDb Builders](builders/tmdb) * [TVDb Builders](builders/tvdb) * [IMDb Builders](builders/imdb) diff --git a/docs/metadata/overlay.md b/docs/metadata/overlay.md index 0877a0a1..1915d129 100644 --- a/docs/metadata/overlay.md +++ b/docs/metadata/overlay.md @@ -73,6 +73,20 @@ overlays: imdb_chart: top_movies ``` +#### Blurring Overlay + +There is a special overlay named `blur` that when given as the overlay name will instead of finding the image will just blur the image instead. + +```yaml +overlays: + blur: + overlay: + name: blur + plex_search: + all: + resolution: 4K +``` + ### Supress Overlays You can add `supress_overlays` to an overlay definition and give it a list or comma separated string of overlay names you want suppressed from this item if this overlay is attached to the item. diff --git a/modules/builder.py b/modules/builder.py index dc09e0f1..1e3e99b2 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -305,7 +305,7 @@ class CollectionBuilder: self.overlay = self.mapping_name logger.warning(f"{self.Type} Warning: No overlay attribute using mapping name {self.mapping_name} as the overlay name") overlay_path = os.path.join(library.overlay_folder, f"{self.overlay}.png") - if not os.path.exists(overlay_path): + if self.overlay != "blur" and not os.path.exists(overlay_path): raise Failed(f"{self.Type} Error: Overlay Image not found at: {overlay_path}") if "supress_overlays" in methods: diff --git a/modules/overlays.py b/modules/overlays.py index da0da688..8517453f 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -4,7 +4,7 @@ from modules.builder import CollectionBuilder from modules.util import Failed from plexapi.exceptions import BadRequest from plexapi.video import Movie, Show, Season, Episode -from PIL import Image +from PIL import Image, ImageFilter logger = util.logger @@ -67,20 +67,24 @@ class Overlays: logger.error(e) for overlay_name, over_keys in overlay_to_keys.items(): - 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_updated[overlay_name] = not image_compare or str(overlay_size) != str(image_compare) - overlay_images[overlay_name] = Image.open(overlay_file).convert("RGBA") + if overlay_name == "blur": + overlay_updated[overlay_name] = False + overlay_images[overlay_name] = None + else: + 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_updated[overlay_name] = not image_compare or str(overlay_size) != str(image_compare) + overlay_images[overlay_name] = Image.open(overlay_file).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) for over_key in over_keys: if over_key not in key_to_overlays: key_to_overlays[over_key] = (key_to_item[over_key], []) key_to_overlays[over_key][1].append(overlay_name) - if self.config.Cache: - self.config.Cache.update_image_map(overlay_name, f"{self.library.image_table_name}_overlays", overlay_name, overlay_size) def find_poster_url(plex_item): if isinstance(plex_item, Movie): @@ -207,8 +211,11 @@ class Overlays: temp = os.path.join(self.library.overlay_folder, f"temp.png") try: for over_name in over_names: - new_poster = new_poster.resize(overlay_images[over_name].size, Image.ANTIALIAS) - new_poster.paste(overlay_images[over_name], (0, 0), overlay_images[over_name]) + if over_name == "blur": + new_poster = new_poster.filter(ImageFilter.GaussianBlur(50)) + else: + new_poster = new_poster.resize(overlay_images[over_name].size, Image.ANTIALIAS) + new_poster.paste(overlay_images[over_name], (0, 0), overlay_images[over_name]) new_poster.save(temp, "PNG") self.library.upload_poster(item, temp) self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False)