[9] catch image connection errors

pull/909/head
meisnate12 2 years ago
parent c417d92cdf
commit 05e6fec48f

@ -1 +1 @@
1.17.0-develop8 1.17.0-develop9

@ -5,6 +5,7 @@ from modules.util import Failed, NotScheduled, NotScheduledRange, Overlay, Delet
from plexapi.audio import Artist, Album, Track from plexapi.audio import Artist, Album, Track
from plexapi.exceptions import BadRequest, NotFound from plexapi.exceptions import BadRequest, NotFound
from plexapi.video import Movie, Show, Season, Episode from plexapi.video import Movie, Show, Season, Episode
from requests.exceptions import ConnectionError
from urllib.parse import quote from urllib.parse import quote
logger = util.logger logger = util.logger
@ -787,11 +788,13 @@ class CollectionBuilder:
def _poster(self, method_name, method_data): def _poster(self, method_name, method_data):
if method_name == "url_poster": if method_name == "url_poster":
try:
image_response = self.config.get(method_data, headers=util.header()) 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"]:
logger.warning(f"{self.Type} Warning: No Poster Found at {method_data}") raise ConnectionError
else:
self.posters[method_name] = method_data self.posters[method_name] = method_data
except ConnectionError:
logger.warning(f"{self.Type} Warning: No Poster Found at {method_data}")
elif method_name == "tmdb_poster": elif method_name == "tmdb_poster":
self.posters[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).poster_url self.posters[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).poster_url
elif method_name == "tmdb_profile": elif method_name == "tmdb_profile":
@ -806,11 +809,13 @@ class CollectionBuilder:
def _background(self, method_name, method_data): def _background(self, method_name, method_data):
if method_name == "url_background": if method_name == "url_background":
try:
image_response = self.config.get(method_data, headers=util.header()) 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"]:
logger.warning(f"{self.Type} Warning: No Background Found at {method_data}") raise ConnectionError
else:
self.backgrounds[method_name] = method_data self.backgrounds[method_name] = method_data
except ConnectionError:
logger.warning(f"{self.Type} Warning: No Background Found at {method_data}")
elif method_name == "tmdb_background": elif method_name == "tmdb_background":
self.backgrounds[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).backdrop_url self.backgrounds[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).backdrop_url
elif method_name == "tvdb_background": elif method_name == "tvdb_background":

Loading…
Cancel
Save