I’m trying to build a plugin for SageTV. For now I just want very basic functionality, list and play recordings. The SageTV webserver can return XML files with info on all of the recordings by passing a URL, and if I enter that URL in Safari I get the XML. The plugin is throwing this error when trying to connect:
22:48:38.260771: com.plexapp.plugins.sagetv : (Framework) Bundle verification complete<br />
22:48:38.261389: com.plexapp.plugins.sagetv : (Framework) Debugging is enabled<br />
22:48:38.261451: com.plexapp.plugins.sagetv : (Framework) Default encoding is utf-8<br />
22:48:38.263697: com.plexapp.plugins.sagetv : (Framework) Loaded en strings<br />
22:48:38.263824: com.plexapp.plugins.sagetv : (Framework) Couldn't find en-us strings<br />
22:48:38.263862: com.plexapp.plugins.sagetv : (Framework) Configured framework modules<br />
22:48:38.268418: com.plexapp.plugins.sagetv : (Framework) Imported plug-in module<br />
22:48:38.268627: com.plexapp.plugins.sagetv : (Framework) Loaded shared resource named 'trust.json'<br />
22:48:38.273011: com.plexapp.plugins.sagetv : (Framework) Checked module imports<br />
22:48:38.273517: com.plexapp.plugins.sagetv : (Framework) Loaded the dictionary file<br />
22:48:38.273718: com.plexapp.plugins.sagetv : (Framework) No cookie jar found<br />
22:48:38.319371: com.plexapp.plugins.sagetv : (Framework) Initialized framework modules<br />
22:48:38.319440: com.plexapp.plugins.sagetv : (Framework) Attempting to start the plug-in...<br />
22:48:38.319501: com.plexapp.plugins.sagetv : (Framework) Added a handler for prefix '/video/sagetv'<br />
22:48:38.402201: com.plexapp.plugins.sagetv : (Framework) Added a view group named 'InfoList'<br />
22:48:38.403524: com.plexapp.plugins.sagetv : (Framework) Plug-in started<br />
22:48:38.403923: com.plexapp.plugins.sagetv : (Framework) Entering run loop<br />
22:48:38.404165: com.plexapp.plugins.sagetv : (Framework) Handling request : /:/prefixes<br />
22:48:38.404456: com.plexapp.plugins.sagetv : (Framework) Resource named 'icon-default.png' of type 'image/png' was made public.<br />
22:48:38.404655: com.plexapp.plugins.sagetv : (Framework) Resource named 'art-default.png' of type 'image/png' was made public.<br />
22:48:38.404958: com.plexapp.plugins.sagetv : (Framework) Response OK<br />
22:48:38.406530: com.plexapp.plugins.sagetv : (Framework) Handling request : /:/prefixes<br />
22:48:38.407137: com.plexapp.plugins.sagetv : (Framework) Response OK<br />
<br />
22:50:31.752547: com.plexapp.plugins.sagetv : (Framework) Loaded en strings<br />
22:50:31.752934: com.plexapp.plugins.sagetv : (Framework) Handling request : /video/sagetv<br />
22:50:31.753224: com.plexapp.plugins.sagetv : (Framework) Response OK<br />
22:50:34.265619: com.plexapp.plugins.sagetv : (Framework) Handling request : /video/sagetv/:/function/all_shows/KGRwMApTJ3BhZ2VVcmwnCnAxClMnaHR0cDovL2Fhcm9uOmVybmllMTk4MUAxOTIuMTY4LjAuMTA6ODA4My9zYWdlL1JlY29yZGluZ3M@eG1sPXllcycKcDIKc1Mnc2VuZGVyJwpwMwpjY29weV9yZWcKX3JlY29uc3RydWN0b3IKcDQKKGNQTVMuT2JqZWN0cwpJdGVtSW5mb1JlY29yZApwNQpjX19idWlsdGluX18Kb2JqZWN0CnA2Ck50cDcKUnA4CihkcDkKUydpdGVtVGl0bGUnCnAxMApTJ1Nob3dzJwpwMTEKc1MndGl0bGUxJwpwMTIKTnNTJ3RpdGxlMicKcDEzCk5zUydhcnQnCnAxNApOc2JzLg__<br />
22:50:34.266820: com.plexapp.plugins.sagetv : (Framework) Calling named function 'all_shows'<br />
22:50:34.268432: com.plexapp.plugins.sagetv : (Framework) URLError when requesting 'http://username:password@192.168.0.10:8083/sage/Recordings?xml=yes'<br />
22:50:34.268649: com.plexapp.plugins.sagetv : (Framework) An exception happened:<br />
Traceback (most recent call last):<br />
File "/Users/aaron/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/PMS/Plugin.py", line 640, in __call<br />
return function(*args, **kwargs)<br />
File "/Users/aaron/Library/Application Support/Plex Media Server/Plug-ins/SageTV.bundle/Contents/Code/__init__.py", line 42, in all_shows<br />
for item in content.xpath('/showlist//segment'):<br />
AttributeError: 'NoneType' object has no attribute 'xpath'<br />
<br />
22:50:34.268735: com.plexapp.plugins.sagetv : (Framework) Request not handled by plug-in<br />
<br />
22:50:36.973326: com.plexapp.plugins.sagetv : (Framework) Handling request : /video/sagetv/:/function/all_shows/KGRwMApTJ3BhZ2VVcmwnCnAxClMnaHR0cDovL2Fhcm9uOmVybmllMTk4MUAxOTIuMTY4LjAuMTA6ODA4My9zYWdlL1JlY29yZGluZ3M@eG1sPXllcycKcDIKc1Mnc2VuZGVyJwpwMwpjY29weV9yZWcKX3JlY29uc3RydWN0b3IKcDQKKGNQTVMuT2JqZWN0cwpJdGVtSW5mb1JlY29yZApwNQpjX19idWlsdGluX18Kb2JqZWN0CnA2Ck50cDcKUnA4CihkcDkKUydpdGVtVGl0bGUnCnAxMApTJ1Nob3dzJwpwMTEKc1MndGl0bGUxJwpwMTIKTnNTJ3RpdGxlMicKcDEzCk5zUydhcnQnCnAxNApOc2JzLg__<br />
22:50:36.974433: com.plexapp.plugins.sagetv : (Framework) Calling named function 'all_shows'<br />
**22:50:36.975129: com.plexapp.plugins.sagetv : (Framework) URLError when requesting 'http://username:password@192.168.0.10:8083/sage/Recordings?xml=yes'**<br />
22:50:36.975399: com.plexapp.plugins.sagetv : (Framework) An exception happened:<br />
Traceback (most recent call last):<br />
File "/Users/aaron/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/PMS/Plugin.py", line 640, in __call<br />
return function(*args, **kwargs)<br />
File "/Users/aaron/Library/Application Support/Plex Media Server/Plug-ins/SageTV.bundle/Contents/Code/__init__.py", line 42, in all_shows<br />
for item in content.xpath('/showlist//segment'):<br />
AttributeError: 'NoneType' object has no attribute 'xpath'<br />
<br />
22:50:36.975490: com.plexapp.plugins.sagetv : (Framework) Request not handled by plug-in
I am complete novice with Python, I copied some code form a different plugin to get started. The very limited pieces I've built so far seem to be working OK. Code is below. My username and password are hardcoded for now, changed in the pasted code for obvious reasons. Thanks in advance for any help
####################################################################################################<br />
from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
####################################################################################################<br />
<br />
VIDEO_PREFIX = "/video/sagetv"<br />
<br />
SAGE_URL = "http://username:password@192.168.0.10:8083/sage/Recordings?xml=yes"<br />
SAGE_WATCH_URL = "http://username:password@192.168.0.10:8083/sage/Recordings?xml=yes"<br />
CACHE_INTERVAL = 3600<br />
DEBUG = True<br />
ART = 'art-default.png'<br />
ICON = 'icon-default.png'<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, L("SageTV Plugin"))<br />
Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
dir = MediaContainer(mediaType='video')<br />
dir.Append(<br />
Function(<br />
DirectoryItem(<br />
all_shows,<br />
title="Shows",<br />
summary="Browse Show List"<br />
),<br />
pageUrl = SAGE_WATCH_URL<br />
)<br />
)<br />
return dir<br />
<br />
####################################################################################################<br />
def all_shows(sender, pageUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
content = XML.ElementFromURL(pageUrl, True)<br />
for item in content.xpath('/showlist//segment'):<br />
titleUrl = item.get('filePath')<br />
Log(titleUrl)<br />
dir.Append(Function(DirectoryItem(VideoPage, titleUrl), titleUrl = SAGE_URL+titleUrl))<br />
return dir <br />
<br />
####################################################################################################<br />
def VideoPage(sender, titleUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
content = XML.ElementFromURL(titleUrl, True)<br />
for item2 in content.xpath('//div[@class="img"]//a'):<br />
vidUrl = item2.xpath(".")[0].get('href')<br />
vidUrl = SAGE_URL+vidUrl <br />
Log(vidUrl)<br />
image2 = item2.xpath(".//img")[0].get('src')<br />
Log(image2)<br />
title2 = item2.xpath(".")[0].get('href')<br />
Log(title2)<br />
dir.Append(WebVideoItem(vidUrl, thumb=image2, title=title2))<br />
return dir
(and even if they we’re direct children you would have found them with the double slash too).