[10] Add blur overlay

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

@ -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

@ -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 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.

@ -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)

@ -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.

@ -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:

@ -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)

Loading…
Cancel
Save