[3] Added webp Image Support

pull/1243/head
meisnate12 2 years ago
parent 7a0fbc88ef
commit 1540bc4bf5

@ -1,7 +1,8 @@
# Requirements Update (requirements will need to be reinstalled)
# New Features
Added new collection_order `custom.desc`. ([FR](https://features.metamanager.wiki/features/p/reverse-sort-collectionorder-custom))
Added new collection_order `custom.desc` ([FR](https://features.metamanager.wiki/features/p/reverse-sort-collectionorder-custom))
Added webp Image Support ([FR](https://features.metamanager.wiki/features/p/support-webp-image-extensions))
# Bug Fixes
Fixed Italian Translation
Fixed Italian Translation

@ -1 +1 @@
1.18.1-develop2
1.18.1-develop3

@ -898,7 +898,7 @@ class CollectionBuilder:
if method_name == "url_poster":
try:
image_response = self.config.get(method_data, headers=util.header())
if image_response.status_code >= 400 or image_response.headers["Content-Type"] not in ["image/jpeg", "image/png"]:
if image_response.status_code >= 400 or image_response.headers["Content-Type"] not in ["image/jpeg", "image/png", "image/webp"]:
raise ConnectionError
self.posters[method_name] = method_data
except ConnectionError:
@ -925,7 +925,7 @@ class CollectionBuilder:
if method_name == "url_background":
try:
image_response = self.config.get(method_data, headers=util.header())
if image_response.status_code >= 400 or image_response.headers["Content-Type"] not in ["image/jpeg", "image/png"]:
if image_response.status_code >= 400 or image_response.headers["Content-Type"] not in ["image/jpeg", "image/png", "image/webp"]:
raise ConnectionError
self.backgrounds[method_name] = method_data
except ConnectionError:

@ -179,9 +179,14 @@ class Overlays:
image_response = self.config.get(new_backup)
if image_response.status_code >= 400:
raise Failed(f"{item_title[:60]:<60} | Overlay Error: Image Download Failed")
if image_response.headers["Content-Type"] not in ["image/png", "image/jpeg"]:
raise Failed(f"{item_title[:60]:<60} | Overlay Error: Image Not JPG or PNG")
i_ext = "jpg" if image_response.headers["Content-Type"] == "image/jpeg" else "png"
if image_response.headers["Content-Type"] not in ["image/png", "image/jpeg", "image/webp"]:
raise Failed(f"{item_title[:60]:<60} | Overlay Error: Image Not PNG, JPG, or WEBP")
if image_response.headers["Content-Type"] == "image/jpeg":
i_ext = "jpg"
elif image_response.headers["Content-Type"] == "image/webp":
i_ext = "webp"
else:
i_ext = "png"
backup_image_path = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.{i_ext}")
with open(backup_image_path, "wb") as handler:
handler.write(image_response.content)

@ -1239,7 +1239,7 @@ class Plex(Library):
if is_top_level and self.asset_folders and self.dimensional_asset_rename and (not poster or not background):
for file in util.glob_filter(os.path.join(item_asset_directory, "*.*")):
if file.lower().endswith((".jpg", ".png", ".jpeg")):
if file.lower().endswith((".png", ".jpg", ".jpeg", "webp")):
try:
image = Image.open(file)
_w, _h = image.size

Loading…
Cancel
Save