Hey all,
I’ve decided to try my hand at writing a plugin for Plex, my ISP offers around 30 free IPTV channels, so why not add them to Plex!?
Anyway, I’ve followed a few guides and have developed some code I’d like to test out. I’ve constructed an init.py file, but don’t really know where to go from here.
I’ve created a tpgtv.bundle file, with the following tree structure… is this all I need to do?
mikesMacBookPro:tpgtv.bundle mike$ ls -lR<br />
drwxr-xr-x 4 mike staff 136 9 Jan 19:20 Contents<br />
<br />
./Contents:<br />
drwxr-xr-x 3 mike staff 102 9 Jan 19:20 Code<br />
drwxr-xr-x 3 mike staff 102 8 Jan 13:38 Resources<br />
<br />
./Contents/Code:<br />
-rw-r--r-- 1 mike staff 2818 9 Jan 19:20 __init__.py<br />
<br />
./Contents/Resources:<br />
-rw-r--r--@ 1 mike staff 3011 8 Jan 13:29 icon-default.gif
Here is my code too - if someone with experienced eyes can gaze over it and point our any errors I'd appreciate it too
#####################################################################<br />
#<br />
# File: __init__.py<br />
# Author: mistat<br />
# Date: 09/01/2012<br />
# Version: 0.1<br />
# About: This plugin will enable applicable TPG <br />
# (www.tpg.com.au) customers to view the TPG IPTV <br />
# Channels through Plex Media Server. Note: Some <br />
# channels require authentication, as such they may not<br />
# work through this plugin - unless you authenticate <br />
# through the TPG IPTV Website first.<br />
#<br />
#####################################################################<br />
<br />
# PMS plugin framework<br />
from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
#####################################################################<br />
<br />
TITLE = 'TPGTV'<br />
VIDEO_PREFIX = '/video/tpgtv'<br />
IPTV_PLAYLIST = 'http://www.tpg.com.au/iptv/playlist.php'<br />
ART = 'art-default.jpg'<br />
ICON = 'icon-default.gif'<br />
<br />
#####################################################################<br />
<br />
def Start():<br />
<br />
# Initialize the plug-in<br />
Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, NAME, ICON, ART)<br />
Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items")<br />
Plugin.AddViewGroup("List", viewMode="List", mediaType="items")<br />
Plugin.AddViewGroup("InfoList", viewMode = "InfoList", mediaType = "items")<br />
Plugin.AddViewGroup('EpisodeList', viewMode='Episodes', mediaType='items')<br />
<br />
# Setup the default attributes for the ObjectContainer<br />
ObjectContainer.title1 = TITLE<br />
ObjectContainer.view_group = 'List'<br />
ObjectContainer.art = R(ART)<br />
<br />
# Setup the default attributes for the other objects<br />
DirectoryObject.thumb = R(ICON)<br />
DirectoryObject.art = R(ART)<br />
VideoClipObject.thumb = R(ICON)<br />
VideoClipObject.art = R(ART)<br />
<br />
#####################################################################<br />
<br />
@handler('/video/tpgtv', TITLE)<br />
def MainMenu():<br />
oc = ObjectContainer()<br />
<br />
for stream in XML.ElementFromURL(IPTV_PLAYLIST).xpath('//track'): <br />
url = video.xpath('./location')[0].text<br />
title = video.xpath('./title')[0].text<br />
<br />
# Find Thumb from another page<br />
thumbTitle = title.lower()<br />
thumbTitle.replace(' ','') <br />
thumb = 'http://www.tpg.com.au/iptv/img/logo_' + thumbTitle + '_s.gif'<br />
<br />
oc.add(VideoClipObject(<br />
url = url,<br />
title = title,<br />
thumb = Callback(Thumb, url=thumb),<br />
<br />
return oc<br />
<br />
#####################################################################<br />
<br />
def Thumb(url):<br />
try:<br />
data = HTTP.Request(url, cacheTime = CACHE_1MONTH).content<br />
return DataObject(data, 'image/jpeg')<br />
except:<br />
return Redirect(R(ICON))<br />
<br />
#####################################################################
