From baf44a97b44f448ef2af58c42b9f9336befed686 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 11 May 2016 22:01:38 -0700 Subject: [PATCH] Use PMSConnect to retireve notification poster --- plexpy/notification_handler.py | 11 +++++++---- plexpy/pmsconnect.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index d4a424bd..d2898578 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -20,7 +20,6 @@ import os import re import threading import time -import urllib import plexpy import config @@ -635,11 +634,15 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id= if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS: try: thread_name = str(threading.current_thread().ident) - poster_file = os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-' + thread_name) + poster_file = os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-%s' % thread_name) # Retrieve the poster from Plex and cache to file - urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN, - poster_file) + result = pms_connect.get_image(img=thumb) + if result and result[0]: + with open(poster_file, 'wb') as f: + f.write(result[0]) + else: + raise Exception(u'PMS request failed') # Upload thumb to Imgur and get link poster_url = helpers.uploadToImgur(poster_file, poster_title) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 182df2e5..65eab009 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1890,7 +1890,7 @@ class PmsConnect(object): return labels_list - def get_image(self, img=None, width=None, height=None): + def get_image(self, img=None, width='1000', height='1500'): """ Return image data as array. Array contains the image content type and image binary