From 52361cd505c9b17cc138ab07cca8111dbab5be2a Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sun, 20 Mar 2016 17:06:58 -0700 Subject: [PATCH] Catch error if unable to retrieve poster for notification --- plexpy/notification_handler.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 18828e68..dbbbcbf9 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -625,11 +625,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id= # If no previous poster_url if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS: - # Retrieve the poster from Plex and cache to file - urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN, - os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg')) - # Upload thumb to Imgur and get link - poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'), poster_title) + try: + # Retrieve the poster from Plex and cache to file + urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN, + os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg')) + # Upload thumb to Imgur and get link + poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'), poster_title) + except Exception as e: + logger.error(u"PlexPy Notifier :: Unable to retrieve poster for rating_key %s: %s." % (str(rating_key), e)) metadata['poster_url'] = poster_url