Skip to content

Commit

Permalink
Add a bit more details to some errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
chazlarson committed Nov 25, 2023
1 parent 19dac0b commit 9c2f91b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion modules/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def check_image_for_overlay(self, image_url, image_path, remove=False):
exif_tags = image.getexif()
if 0x04bc in exif_tags and exif_tags[0x04bc] == "overlay":
os.remove(image_path)
raise Failed("Poster already has an Overlay")
raise Failed("This item's poster already has an Overlay. There is no PMM setting to change; manual attention required.")
if remove:
os.remove(image_path)
else:
Expand Down
2 changes: 1 addition & 1 deletion modules/mdblist.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ def get_tmdb_ids(self, method, data, is_movie=None):
results.append((item["id"], "tmdb" if item["mediatype"] == "movie" else "tmdb_show"))
return results
except JSONDecodeError:
raise Failed(f"Mdblist Error: Invalid Response")
raise Failed(f"Mdblist Error: Invalid JSON Response received")
else:
raise Failed(f"Mdblist Error: Method {method} not supported")
2 changes: 1 addition & 1 deletion modules/notifiarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, config, params):
try:
self.request(path="user", params={"fetch": "settings"})
except JSONDecodeError:
raise Failed("Notifiarr Error: Invalid response")
raise Failed("Notifiarr Error: Invalid JSON response received")

def notification(self, json):
return self.request(json=json)
Expand Down
4 changes: 3 additions & 1 deletion modules/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ def color(attr):

def get_and_save_image(image_url):
response = self.config.get(image_url)
if response.status_code >= 400:
if response.status_code == 404:
raise Failed(f"Overlay Error: Overlay Image not found at: {image_url}")
if response.status_code >= 400:
raise Failed(f"Overlay Error: Status {response.status_code} when attempting download of: {image_url}")
if "Content-Type" not in response.headers or response.headers["Content-Type"] != "image/png":
raise Failed(f"Overlay Error: Overlay Image not a png: {image_url}")
if not os.path.exists(library.overlay_folder) or not os.path.isdir(library.overlay_folder):
Expand Down
2 changes: 1 addition & 1 deletion modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ def find_item_assets(self, item, item_asset_directory=None, asset_directory=None
else:
starting = item
if not starting.locations:
raise Failed(f"Asset Warning: No video filepath found fo {item.title}")
raise Failed(f"Asset Warning: No video filepath found for {item.title}")
path_test = str(starting.locations[0])
if not os.path.dirname(path_test):
path_test = path_test.replace("\\", "/")
Expand Down
4 changes: 3 additions & 1 deletion modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ def quote(data):

def download_image(title, image_url, download_directory, filename=None):
response = requests.get(image_url, headers=header())
if response.status_code == 404:
raise Failed(f"Image Error: Not Found on Image URL: {image_url}")
if response.status_code >= 400:
raise Failed(f"Image Error: Failed to download Image URL: {image_url}")
raise Failed(f"Image Error: {response.status_code} on Image URL: {image_url}")
if "Content-Type" not in response.headers or response.headers["Content-Type"] not in image_content_types:
raise Failed("Image Not PNG, JPG, or WEBP")
new_image = os.path.join(download_directory, f"{filename}") if filename else download_directory
Expand Down

0 comments on commit 9c2f91b

Please sign in to comment.