add webp support for overlays

pull/2024/head
Yozora XCII 7 months ago
parent 0c13d88dde
commit 26127aa79d

1
.gitignore vendored

@ -18,6 +18,7 @@ config/overlays/*/
config/overlays/temp.jpeg config/overlays/temp.jpeg
config/overlays/temp.jpg config/overlays/temp.jpg
config/overlays/temp.png config/overlays/temp.png
config/overlays/temp.webp
!config/*.template !config/*.template
build/ build/
develop-eggs/ develop-eggs/

@ -3,18 +3,17 @@
# Removed Features # Removed Features
# New Features # New Features
Added `overlay_filetype` and `overlay_quality` settings to control the filetype and quality of overlay images. Added `overlay_filetype` and `overlay_quality` settings to control the filetype and quality of overlay images. Users can select from JPG, PNG and WEBP.
# Updates # Updates
# Defaults # Defaults
Added `starting_only` template variable to the `mal` Collection Default. Added `starting_only` template variable to the `mal` Collection Default.
Changed streaming defaults to use names as their keys vs their TMDb IDs as keys Changed streaming defaults to use names as their keys vs their TMDb IDs as keys
Fixed `amazon` ID in `streaming` when region is `CA`
# Bug Fixes # Bug Fixes
Catch bad ID data from Plex Catch bad ID data from Plex
Fixes `- git` file calls Fixes `- git` file calls
Various other Minor Fixes Various other Minor Fixes
Closed legacy issues on GitHub

@ -26,27 +26,33 @@ templates:
conditions: conditions:
- originals_only: false - originals_only: false
value: <<limit>> value: <<limit>>
discover_with:
conditions:
- originals_only: false
value: <<tmdb_key>>
discover_region: discover_region:
conditions: conditions:
- originals_only: false - originals_only: false
value: <<region>> value: <<region>>
final_tmdb_key:
default: <<tmdb_key>>
conditions:
- region: CA
tmdb_key: [9]
value: 119
discover_with:
conditions:
- originals_only: false
value: <<final_tmdb_key>>
allowed_streaming: allowed_streaming:
conditions: conditions:
- originals_only: true - originals_only: true
tmdb_key: ["103", "1759", "151", "230", "283", "510", "39", "37", "188"] tmdb_key: [103, 1759, 151, 230, 283, 510, 39, 37, 188]
value: False value: False
- region.not: GB - region.not: GB
tmdb_key: ["103", "151", "39"] tmdb_key: [103, 151, 39]
value: False value: False
- region.not: CA - region.not: CA
tmdb_key: ["230"] tmdb_key: [230]
value: False value: False
- region: CA - region: CA
tmdb_key: ["1899", "37"] tmdb_key: [1899, 37]
value: False value: False
default: default:

@ -75,24 +75,30 @@ templates:
discover_with: discover_with:
conditions: conditions:
- originals_only: false - originals_only: false
value: <<tmdb_key>> value: <<final_tmdb_key>>
discover_region: discover_region:
conditions: conditions:
- originals_only: false - originals_only: false
value: <<region>> value: <<region>>
final_tmdb_key:
default: <<tmdb_key>>
conditions:
- region: CA
tmdb_key: [9]
value: 119
allowed_streaming: allowed_streaming:
conditions: conditions:
- originals_only: true - originals_only: true
tmdb_key: ["103", "1759", "151", "230", "283", "510", "39", "37", "188"] tmdb_key: [103, 1759, 151, 230, 283, 510, 39, 37, 188]
value: False value: False
- region.not: GB - region.not: GB
tmdb_key: ["103", "151", "39"] tmdb_key: [103, 151, 39]
value: False value: False
- region.not: CA - region.not: CA
tmdb_key: ["230"] tmdb_key: [230]
value: False value: False
- region: CA - region: CA
tmdb_key: ["1899", "37"] tmdb_key: [1899, 37]
value: False value: False
mdblist_list: https://mdblist.com/lists/k0meta/<<key>>-<<originals>> mdblist_list: https://mdblist.com/lists/k0meta/<<key>>-<<originals>>
tmdb_discover: tmdb_discover:
@ -103,73 +109,73 @@ templates:
overlays: overlays:
Netflix: Netflix:
variables: {key: netflix, tmdb_key: "8", weight: 160} variables: {key: netflix, tmdb_key: 8, weight: 160}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Prime: Prime:
variables: {key: amazon, tmdb_key: "9", weight: 150} variables: {key: amazon, tmdb_key: 9, weight: 150}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Disney: Disney:
variables: {key: disney, tmdb_key: "337", weight: 140} variables: {key: disney, tmdb_key: 337, weight: 140}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Max: Max:
variables: {key: max, tmdb_key: "1899", weight: 130} variables: {key: max, tmdb_key: 1899, weight: 130}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Crunchyroll: Crunchyroll:
variables: {key: crunchyroll, tmdb_key: "283", weight: 120, allowed_libraries: show} variables: {key: crunchyroll, tmdb_key: 283, weight: 120, allowed_libraries: show}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
YouTube: YouTube:
variables: {key: youtube, tmdb_key: "188", weight: 110} variables: {key: youtube, tmdb_key: 188, weight: 110}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Hulu: Hulu:
variables: {key: hulu, tmdb_key: "15", weight: 100} variables: {key: hulu, tmdb_key: 15, weight: 100}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Paramount: Paramount:
variables: {key: paramount, tmdb_key: "531", weight: 90} variables: {key: paramount, tmdb_key: 531, weight: 90}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
AppleTV: AppleTV:
variables: {key: appletv, tmdb_key: "350", weight: 80} variables: {key: appletv, tmdb_key: 350, weight: 80}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Peacock: Peacock:
variables: {key: peacock, tmdb_key: "387", weight: 70} variables: {key: peacock, tmdb_key: 387, weight: 70}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Showtime: Showtime:
variables: {key: showtime, tmdb_key: "37", weight: 60} variables: {key: showtime, tmdb_key: 37, weight: 60}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
discovery+: discovery+:
variables: {key: discovery, tmdb_key: "510", weight: 58, allowed_libraries: show} variables: {key: discovery, tmdb_key: 510, weight: 58, allowed_libraries: show}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
Crave: Crave:
variables: {key: crave, tmdb_key: "230", weight: 55} variables: {key: crave, tmdb_key: 230, weight: 55}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
NOW: NOW:
variables: {key: now, tmdb_key: "39", weight: 50} variables: {key: now, tmdb_key: 39, weight: 50}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
All 4: All 4:
variables: {key: all4, tmdb_key: "103", weight: 40} variables: {key: all4, tmdb_key: 103, weight: 40}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
britbox: britbox:
variables: {key: britbox, tmdb_key: "151", weight: 30} variables: {key: britbox, tmdb_key: 151, weight: 30}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
BET+: BET+:
variables: {key: bet, tmdb_key: "1759", weight: 20} variables: {key: bet, tmdb_key: 1759, weight: 20}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]
hayu: hayu:
variables: {key: hayu, tmdb_key: "223", weight: 10, allowed_libraries: show} variables: {key: hayu, tmdb_key: 223, weight: 10, allowed_libraries: show}
template: [name: standard, name: mdb_streaming] template: [name: standard, name: mdb_streaming]

@ -1002,20 +1002,22 @@ The available setting attributes which can be set at each level are outlined bel
<table class="clearTable"> <table class="clearTable">
<tr><td>`jpg`</td><td>Use JPG files for saving Overlays</td></tr> <tr><td>`jpg`</td><td>Use JPG files for saving Overlays</td></tr>
<tr><td>`png`</td><td>Use PNG files for saving Overlays</td></tr> <tr><td>`png`</td><td>Use PNG files for saving Overlays</td></tr>
<tr><td>`webp`</td><td>Use WEBP files for saving Overlays</td></tr>
</table> </table>
**Default Value:** `jpg` **Default Value:** `jpg`
???+ example "Example" ???+ example "Example"
```yaml
```yaml ```yaml
settings: settings:
overlay_filetype: png overlay_filetype: png
``` ```
??? blank "`overlay_quality` - Used to control the JPG quality used with overlay images.<a class="headerlink" href="#overlay-quality" title="Permanent link"></a>" ??? blank "`overlay_quality` - Used to control the JPG or WEBP quality used with overlay images.<a class="headerlink" href="#overlay-quality" title="Permanent link"></a>"
<div id="overlay-quality" />Used to control the JPG quality used with overlay images. <div id="overlay-quality" />Used to control the JPG or WEBP quality used with overlay images.
<hr style="margin: 0px;"> <hr style="margin: 0px;">

@ -898,10 +898,10 @@
}, },
"overlay_filetype": { "overlay_filetype": {
"description": "Used to control the filetype used with overlay images.", "description": "Used to control the filetype used with overlay images.",
"enum": ["jpg", "png"] "enum": ["jpg", "png", "webp"]
}, },
"overlay_quality": { "overlay_quality": {
"description": "Used to control the JPG quality used with overlay images.", "description": "Used to control the JPG or WEBP quality used with overlay images.",
"type": "integer", "type": "integer",
"minimum": 1, "minimum": 1,
"maximum": 100 "maximum": 100

@ -43,7 +43,8 @@ run_order_options = {
sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"} sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"}
filetype_list = { filetype_list = {
"jpg": "Use JPG files for saving Overlays", "jpg": "Use JPG files for saving Overlays",
"png": "Use PNG files for saving Overlays" "png": "Use PNG files for saving Overlays",
"webp": "Use WEBP files for saving Overlays"
} }
imdb_label_options = { imdb_label_options = {
"remove": "Remove All IMDb Parental Labels", "remove": "Remove All IMDb Parental Labels",

@ -61,7 +61,8 @@ class Overlays:
logger.ghost(f"Restoring: {i}/{len(remove_overlays)} {item_title}") logger.ghost(f"Restoring: {i}/{len(remove_overlays)} {item_title}")
self.remove_overlay(item, item_title, "Overlay", [ self.remove_overlay(item, item_title, "Overlay", [
os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png"), os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png"),
os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg") os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg"),
os.path.join(self.library.overlay_backup, f"{item.ratingKey}.webp")
]) ])
logger.exorcise() logger.exorcise()
else: else:
@ -176,11 +177,15 @@ class Overlays:
os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")) os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png"))
if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")): if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")):
os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")) os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg"))
if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.webp")):
os.remove(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.webp"))
elif has_overlay: elif has_overlay:
if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")): if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")):
has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png") has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")
elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")): elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")):
has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg") has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")
elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.webp")):
has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.webp")
if self.library.reset_overlays: if self.library.reset_overlays:
reset_list = self.library.reset_overlays reset_list = self.library.reset_overlays
elif has_original is None and not self.library.reset_overlays: elif has_original is None and not self.library.reset_overlays:
@ -508,7 +513,7 @@ class Overlays:
overlay_box = current_overlay.get_coordinates((canvas_width, canvas_height), box=current_overlay.image.size, new_cords=cord) 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) new_poster.paste(current_overlay.image, overlay_box, current_overlay.image)
temp = os.path.join(self.library.overlay_folder, f"temp.{self.library.overlay_filetype}") 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: if self.library.overlay_quality and self.library.overlay_filetype in ["jpg", "webp"]:
new_poster.save(temp, exif=exif_tags, quality=self.library.overlay_quality) new_poster.save(temp, exif=exif_tags, quality=self.library.overlay_quality)
else: else:
new_poster.save(temp, exif=exif_tags) new_poster.save(temp, exif=exif_tags)

@ -1350,7 +1350,7 @@ class Plex(Library):
elif self.show_missing_assets: elif self.show_missing_assets:
logger.warning(f"Asset Warning: No poster or background found in the assets folder '{item_dir}'") logger.warning(f"Asset Warning: No poster or background found in the assets folder '{item_dir}'")
else: else:
logger.warning(f"Asset Warning: {name} has an Overlay and will be updated when overlays are run") logger.info(f"Item: {name} has an Overlay and will be updated when overlays are run")
except Failed as e: except Failed as e:
if self.show_missing_assets: if self.show_missing_assets:
logger.warning(e) logger.warning(e)

Loading…
Cancel
Save