Use PMSConnect to retireve notification poster

This commit is contained in:
JonnyWong16 2016-05-11 22:01:38 -07:00
parent c14053a199
commit baf44a97b4
2 changed files with 8 additions and 5 deletions

View file

@ -20,7 +20,6 @@ import os
import re import re
import threading import threading
import time import time
import urllib
import plexpy import plexpy
import config 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: if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
try: try:
thread_name = str(threading.current_thread().ident) 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 # Retrieve the poster from Plex and cache to file
urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN, result = pms_connect.get_image(img=thumb)
poster_file) 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 # Upload thumb to Imgur and get link
poster_url = helpers.uploadToImgur(poster_file, poster_title) poster_url = helpers.uploadToImgur(poster_file, poster_title)

View file

@ -1890,7 +1890,7 @@ class PmsConnect(object):
return labels_list 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. Return image data as array.
Array contains the image content type and image binary Array contains the image content type and image binary