Hi I need some help. I am trying to build a very basic channel thing for watching my thheadend channels trough PMC / PHT via PMS.
When I say very basic i just need to parse an xml file (that for the time being I am coding by hand). And with the info from the xml file build a list with my channels. No EPG or icons or anything like that at the moment.
Well here is what I have done so far
################################################################################################### NAME = 'TVHeadend' ART = 'art-default.jpg' ICON = 'icon-default.png' PLUGIN_PREFIX = '/video/tvheadend' structure = 'stream/channelid' htsurl = 'http://%s:%s@%s:%s/%s/' % (Prefs['tvheadend_user'], Prefs['tvheadend_pass'], Prefs['tvheadend_host'], Prefs['tvheadend_port'], structure) ####################################################################################################def Start():
Plugin.AddPrefixHandler(PLUGIN_PREFIX, MainMenu, NAME, ICON, ART)ObjectContainer.art = R(ART) #objectContainer.title1 = NAME TrackObject.thumb = R(ICON)####################################################################################################
def MainMenu():
oc = ObjectContainer(no_cache = True) oc.add(DirectoryObject(key = Callback(ChannelsMenu, title = L('Channels')), title = L('Channels'))) oc.add(DirectoryObject(key = Callback(XmlMenu, title = L('Xml')), title = L('Xml'))) oc.add(PrefsObject(title = L('Preferences'))) return ocdef ChannelsMenu(title):
oc = ObjectContainer(view_group=‘InfoList’)oc = ObjectContainer(title1="Channels") mo = MediaObject(parts=[PartObject(key=HTTPLiveStreamURL("%s25" % (htsurl)))]) vco = VideoClipObject(title="C More Sport", url='%s25' % (htsurl)) vco.add(mo) oc.add(vco) return ocdef XmlMenu(title):
oc = ObjectContainer(view_group=‘InfoList’)
oc = ObjectContainer(title1=“Channels”)
from xml.dom import minidom
xmldoc = minidom.parse(‘channels.xml’)
itemlist = xmldoc.getElementsByTagName(‘channel’)
##code below is just what i used to see that could print out what was in the xml file in python.
#print len(itemlist)
#print itemlist[0].attributes[‘name’].value
#for s in itemlist :
#print s.attributes[‘name’].valuereturn oc
So the part with "
def ChannelsMenu(title):
oc = ObjectContainer(view_group='InfoList')
oc = ObjectContainer(title1="Channels")
mo = MediaObject(parts=[PartObject(key=HTTPLiveStreamURL("%s25" % (htsurl)))])
vco = VideoClipObject(title="C More Sport", url='%s25' % (htsurl))
vco.add(mo)
oc.add(vco)
to build a menu with all channels listed in the xml file.
Two problems i have is that I don't know where I should have the xml file in the plugin structure right now the log complains that it does not find it.
2013-07-03 15:38:43,491 (7fed26ed2700) : DEBUG (runtime:143) - Calling function 'XmlMenu'
2013-07-03 15:38:43,533 (7fed26ed2700) : CRITICAL (sandbox:303) - Exception when calling function 'XmlMenu' (most recent call last):
File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 294, in call_named_function
result = f(*args, **kwargs)
File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/tvheadend.bundle/Contents/Code/__init__.py", line 46, in XmlMenu
xmldoc = minidom.parse('channels.xml')
File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/xml/dom/minidom.py", line 1914, in parse
return expatbuilder.parse(file)
File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/xml/dom/expatbuilder.py", line 922, in parse
fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: 'channels.xml'
The other is that I can't figure out the code how to make it build a menu with the info from the xml file.
I have very little to no knowledge of programming so this is a very high learning curve for me.
Any help on this?
Oh and while we are at it The Preference menu does not show for some reason. And I know that it was working before when I started this project a very long time ago.
DefaultPrefs.json
[
{
"id": "tvheadend_user",
"label": "Username",
"type": "text",
"default": ""
},
{
"id": "tvheadend_pass",
"label": "Password",
"type": "text",
"option": "hidden",
"default": ""
},
{
"id": "tvheadend_host",
"label": "HOST",
"type": "text",
"default": ""
},
{
"id": "tvheadend_port",
"label": "port",
"type": "text",
"default": "9981"
}
]