I am trying to write a plugin to play some IPTV my ISP provides, via rtp streams.
In theory this sounds pretty straight forward, however I am having huge trouble getting this off the ground. If anyone could PLEASE offer some help, I’d really appreciate it!
An XML playlist is provided by my ISP, which is generated dynamically, as not everyone is entitled to the same channels - some locations (ie. Sydney) get 30 channels, where as in Adelaide, I get 5.
I gather all I need to do is to parse this playlist, find the IPTV streams, and add them as videoItems. However, as the error below shows, I am not having any luck!
I've used the basic kick start, and simply edited the __init__.py file to add some custom features, like attempting to parse a XML document, and append menu options based upon the results.
But whenever I enable my for loop as below, I'm met with all the errors show above.
VIDEO_PREFIX = "/video/tpgtv"<br />
<br />
NAME = L('Title')<br />
<br />
# make sure to replace artwork with what you want<br />
# these filenames reference the example files in<br />
# the Contents/Resources/ folder in the bundle<br />
ART = 'art-default.jpg'<br />
ICON = 'icon-default.png'<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
<br />
## make this plugin show up in the 'Video' section<br />
## in Plex. The L() function pulls the string out of the strings<br />
## file in the Contents/Strings/ folder in the bundle<br />
## see also:<br />
## http://dev.plexapp.com/docs/mod_Plugin.html<br />
## http://dev.plexapp.com/docs/Bundle.html#the-strings-directory<br />
Plugin.AddPrefixHandler(VIDEO_PREFIX, VideoMainMenu, NAME, ICON, ART)<br />
<br />
Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
Plugin.AddViewGroup("List", viewMode="List", mediaType="items")<br />
<br />
## set some defaults so that you don't have to<br />
## pass these parameters to these object types<br />
## every single time<br />
## see also:<br />
## http://dev.plexapp.com/docs/Objects.html<br />
MediaContainer.title1 = NAME<br />
MediaContainer.viewGroup = "List"<br />
MediaContainer.art = R(ART)<br />
DirectoryItem.thumb = R(ICON)<br />
VideoItem.thumb = R(ICON)<br />
<br />
HTTP.CacheTime = CACHE_1HOUR<br />
<br />
<br />
<br />
<br />
#### the rest of these are user created functions and<br />
#### are not reserved by the plugin framework.<br />
#### see: http://dev.plexapp.com/docs/Functions.html for<br />
#### a list of reserved functions above<br />
<br />
<br />
<br />
#<br />
# Example main menu referenced in the Start() method<br />
# for the 'Video' prefix handler<br />
#<br />
<br />
def VideoMainMenu():<br />
<br />
<br />
# Container acting sort of like a folder on<br />
# a file system containing other things like<br />
# "sub-folders", videos, music, etc<br />
# see:<br />
# http://dev.plexapp.com/docs/Objects.html#MediaContainer<br />
dir = MediaContainer(viewGroup="InfoList")<br />
<br />
<br />
# see:<br />
# http://dev.plexapp.com/docs/Objects.html#DirectoryItem<br />
# http://dev.plexapp.com/docs/Objects.html#function-objects<br />
dir.Append(<br />
Function(<br />
DirectoryItem(<br />
CallbackExample,<br />
"directory item title",<br />
subtitle="subtitle",<br />
summary="clicking on me will call CallbackExample",<br />
thumb=R(ICON),<br />
art=R(ART)<br />
)<br />
)<br />
)<br />
<br />
for iptvStream in XML.ElementFromURL('http://www.tpg.com.au/iptv/playlist.php',isHTML=true,errors='ignore').xpath('/a:playlist/a:trackList/a:track'):<br />
dir.Append(<br />
Function(<br />
DirectoryItem(<br />
CallbackExample,<br />
"1234",<br />
subtitle="subtitle",<br />
summary="clicking on me will call CallbackExample",<br />
thumb=R(ICON),<br />
art=R(ART)<br />
)<br />
)<br />
)<br />
<br />
<br />
<br />
<br />
# ... and then return the container<br />
return dir<br />
<br />
def CallbackExample(sender):<br />
<br />
## you might want to try making me return a MediaContainer<br />
## containing a list of DirectoryItems to see what happens =)<br />
<br />
return MessageContainer(<br />
"Not implemented",<br />
"In real life, you'll make more than one callback,
and you'll do something useful.
sender.itemTitle=%s" % sender.itemTitle<br />
)
An example of the XML document is:
<?xml version="1.0" encoding="UTF-8"?><br />
<playlist version="1" xmlns="http://xspf.org/ns/0/"><br />
<trackList><br />
<track><br />
<location>rtp://@al-jazeera.iptv.tpg.com.au:1234</location><br />
<title>Al Jazeera</title><br />
</track><br />
<track><br />
<location>rtp://@bloomberg.iptv.tpg.com.au:1234</location><br />
<title>Bloomberg</title><br />
</track><br />
<track><br />
<location>rtp://@cnai.iptv.tpg.com.au:1234</location><br />
<title>Channel News Asia</title><br />
</track><br />
<track><br />
<location>rtp://@phoenix-info-news.iptv.tpg.com.au:1234</location><br />
<title>Phoenix InfoNews</title><br />
</track><br />
<track><br />
<location>rtp://@tv5-monde.iptv.tpg.com.au:1234</location><br />
<title>TV5 Monde</title><br />
</track><br />
<track><br />
<location>rtp://@playboy.iptv.tpg.com.au:1234</location><br />
<title>Playboy TV</title><br />
</track><br />
</trackList><br />
</playlist><br />
<br />