Add error message for PKC playback failure

This commit is contained in:
tomkat83 2017-02-02 08:30:40 +01:00
parent a782075236
commit f82aa0511d

View file

@ -9,7 +9,7 @@ from urlparse import parse_qsl
from xbmc import translatePath, sleep, executebuiltin from xbmc import translatePath, sleep, executebuiltin
from xbmcaddon import Addon from xbmcaddon import Addon
from xbmcgui import ListItem, Dialog from xbmcgui import ListItem
from xbmcplugin import setResolvedUrl from xbmcplugin import setResolvedUrl
_addon = Addon(id='plugin.video.plexkodiconnect') _addon = Addon(id='plugin.video.plexkodiconnect')
@ -32,7 +32,8 @@ sys_path.append(_base_resource)
############################################################################### ###############################################################################
import entrypoint import entrypoint
from utils import window, pickl_window, reset, passwordsXML, language as lang from utils import window, pickl_window, reset, passwordsXML, language as lang,\
dialog
from pickler import unpickle_me from pickler import unpickle_me
from PKC_listitem import convert_PKC_to_listitem from PKC_listitem import convert_PKC_to_listitem
@ -45,7 +46,6 @@ log = logging.getLogger("PLEX.default")
############################################################################### ###############################################################################
ARGV = argv
HANDLE = int(argv[1]) HANDLE = int(argv[1])
@ -54,9 +54,9 @@ class Main():
# MAIN ENTRY POINT # MAIN ENTRY POINT
# @utils.profiling() # @utils.profiling()
def __init__(self): def __init__(self):
log.debug("Full sys.argv received: %s" % ARGV) log.debug("Full sys.argv received: %s" % argv)
# Parse parameters # Parse parameters
params = dict(parse_qsl(ARGV[2][1:])) params = dict(parse_qsl(argv[2][1:]))
try: try:
mode = params['mode'] mode = params['mode']
itemid = params.get('id', '') itemid = params.get('id', '')
@ -67,15 +67,20 @@ class Main():
if mode == 'play': if mode == 'play':
# Put the request into the "queue" # Put the request into the "queue"
while window('plex_play_new_item'): while window('plex_play_new_item'):
sleep(20) sleep(50)
window('plex_play_new_item', window('plex_play_new_item',
value='%s%s' % (mode, ARGV[2])) value='%s%s' % (mode, argv[2]))
# Wait for the result # Wait for the result
while not pickl_window('plex_result'): while not pickl_window('plex_result'):
sleep(20) sleep(50)
result = unpickle_me() result = unpickle_me()
if result is None: if result is None:
log.error('Error encountered, aborting') log.error('Error encountered, aborting')
dialog('notification',
heading='{plex}',
message=lang(30128),
icon='{error}',
time=3000)
setResolvedUrl(HANDLE, False, ListItem()) setResolvedUrl(HANDLE, False, ListItem())
elif result.listitem: elif result.listitem:
listitem = convert_PKC_to_listitem(result.listitem) listitem = convert_PKC_to_listitem(result.listitem)
@ -102,8 +107,8 @@ class Main():
'Plex_Node': entrypoint.Plex_Node 'Plex_Node': entrypoint.Plex_Node
} }
if "/extrafanart" in ARGV[0]: if "/extrafanart" in argv[0]:
plexpath = ARGV[2][1:] plexpath = argv[2][1:]
plexid = params.get('id') plexid = params.get('id')
entrypoint.getExtraFanArt(plexid, plexpath) entrypoint.getExtraFanArt(plexid, plexpath)
entrypoint.getVideoFiles(plexid, plexpath) entrypoint.getVideoFiles(plexid, plexpath)
@ -114,8 +119,8 @@ class Main():
window('plex_runLibScan', value='fanart') window('plex_runLibScan', value='fanart')
# Called by e.g. 3rd party plugin video extras # Called by e.g. 3rd party plugin video extras
if ("/Extras" in ARGV[0] or "/VideoFiles" in ARGV[0] or if ("/Extras" in argv[0] or "/VideoFiles" in argv[0] or
"/Extras" in ARGV[2]): "/Extras" in argv[2]):
plexId = params.get('id', None) plexId = params.get('id', None)
entrypoint.getVideoFiles(plexId, params) entrypoint.getVideoFiles(plexId, params)
@ -153,7 +158,7 @@ class Main():
folderid = params['folderid'] folderid = params['folderid']
modes[mode](itemid, folderid) modes[mode](itemid, folderid)
elif mode == "companion": elif mode == "companion":
modes[mode](itemid, params=ARGV[2]) modes[mode](itemid, params=argv[2])
elif mode == 'Plex_Node': elif mode == 'Plex_Node':
modes[mode](params.get('id'), modes[mode](params.get('id'),
params.get('viewOffset'), params.get('viewOffset'),
@ -167,10 +172,9 @@ class Main():
elif mode in ("manualsync", "repair"): elif mode in ("manualsync", "repair"):
if window('plex_online') != "true": if window('plex_online') != "true":
# Server is not online, do not run the sync # Server is not online, do not run the sync
Dialog().ok( dialog('ok',
lang(29999), heading=lang(29999),
"Unable to run the sync, the add-on is not connected " message=lang(39205))
"to a Plex server.")
log.error("Not connected to a PMS.") log.error("Not connected to a PMS.")
else: else:
if mode == 'repair': if mode == 'repair':