[10] Add blur overlay

pull/858/head
meisnate12 3 years ago
parent 33709b28ee
commit f7d7de36f9

@ -38,9 +38,9 @@ body:
- type: textarea - type: textarea
id: config id: config
attributes: attributes:
label: Relevant Collection/Playlist Definition label: Relevant Collection/Overlay/Playlist Definition
description: > 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. This will be automatically formatted into code, so no need for backticks.
render: yml render: yml
- type: input - type: input

@ -1 +1 @@
1.16.5-develop9 1.16.5-develop10

@ -2,6 +2,8 @@
Smart Builders allow Plex Meta Manager to create Smart Collections in two different ways. Smart Builders allow Plex Meta Manager to create Smart Collections in two different ways.
** Smart Builders do not currently work with Playlists **
## Smart Label ## 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. 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.

@ -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. 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) * [Plex Builders](builders/plex)
* [Smart Builders](builders/smart) * [Smart Builders](builders/smart) (Collections Only)
* [TMDb Builders](builders/tmdb) * [TMDb Builders](builders/tmdb)
* [TVDb Builders](builders/tvdb) * [TVDb Builders](builders/tvdb)
* [IMDb Builders](builders/imdb) * [IMDb Builders](builders/imdb)

@ -73,6 +73,20 @@ overlays:
imdb_chart: top_movies 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 ### 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. 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.

@ -305,7 +305,7 @@ class CollectionBuilder:
self.overlay = self.mapping_name self.overlay = self.mapping_name
logger.warning(f"{self.Type} Warning: No overlay attribute using mapping name {self.mapping_name} as the overlay 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") 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}") raise Failed(f"{self.Type} Error: Overlay Image not found at: {overlay_path}")
if "supress_overlays" in methods: if "supress_overlays" in methods:

@ -4,7 +4,7 @@ from modules.builder import CollectionBuilder
from modules.util import Failed from modules.util import Failed
from plexapi.exceptions import BadRequest from plexapi.exceptions import BadRequest
from plexapi.video import Movie, Show, Season, Episode from plexapi.video import Movie, Show, Season, Episode
from PIL import Image from PIL import Image, ImageFilter
logger = util.logger logger = util.logger
@ -67,6 +67,10 @@ class Overlays:
logger.error(e) logger.error(e)
for overlay_name, over_keys in overlay_to_keys.items(): for overlay_name, over_keys in overlay_to_keys.items():
if overlay_name == "blur":
overlay_updated[overlay_name] = False
overlay_images[overlay_name] = None
else:
clean_name, _ = util.validate_filename(overlay_name) clean_name, _ = util.validate_filename(overlay_name)
image_compare = None image_compare = None
if self.config.Cache: if self.config.Cache:
@ -75,12 +79,12 @@ class Overlays:
overlay_size = os.stat(overlay_file).st_size overlay_size = os.stat(overlay_file).st_size
overlay_updated[overlay_name] = not image_compare or str(overlay_size) != str(image_compare) overlay_updated[overlay_name] = not image_compare or str(overlay_size) != str(image_compare)
overlay_images[overlay_name] = Image.open(overlay_file).convert("RGBA") 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: for over_key in over_keys:
if over_key not in key_to_overlays: if over_key not in key_to_overlays:
key_to_overlays[over_key] = (key_to_item[over_key], []) key_to_overlays[over_key] = (key_to_item[over_key], [])
key_to_overlays[over_key][1].append(overlay_name) 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): def find_poster_url(plex_item):
if isinstance(plex_item, Movie): if isinstance(plex_item, Movie):
@ -207,6 +211,9 @@ class Overlays:
temp = os.path.join(self.library.overlay_folder, f"temp.png") temp = os.path.join(self.library.overlay_folder, f"temp.png")
try: try:
for over_name in over_names: for over_name in over_names:
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 = 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.paste(overlay_images[over_name], (0, 0), overlay_images[over_name])
new_poster.save(temp, "PNG") new_poster.save(temp, "PNG")

Loading…
Cancel
Save