import xbmc, xbmcgui, re, urllib from string import split, replace, find ###################User definable section ###################### # #Modify the variables in this section to suit your individual #installation. Leave these values as strings. # WSHost = "192.168.0.100" WSPort = "8429" VLCHost = "192.168.0.100" VLCPort = "7777" # #####################End user definable section################## # # XBMCJTVLANClient v0.1, Wardhog 16/06/2006 # # Is to be used in conjunction with JTVLAN, a DVB viewing application, # found at jtvlan.netsons.org, and XBMC # # Borrows from Alexpoet's xbmc/Python tutorial, and ConsumptionJunction_v2.py # by ThreeZee # # Emulating = "Emulating" in dir(xbmcgui) #get actioncodes from keymap.xml ACTION_PREVIOUS_MENU = 10 TVStart = "http://" + WSHost + ":" + WSPort + "/servlet/JTVLANServerRes?action=play&channel=" TVStop = "http://" + WSHost + ":" + WSPort + "/servlet/JTVLANServerRes?action=stop" TVStream = "http://" + VLCHost + ":" + VLCPort ChanList = "http://" + WSHost + ":" + WSPort + "/servlet/JTVLANServerRes?action=listchannels" Channels = [] spacecleaner = re.compile(' ') class JTVLANClientObj(xbmcgui.Window): def __init__(self): if Emulating: xbmcgui.Window.__init__(self) Websock = urllib.urlopen(ChanList) ChanData = str(Websock.read()) Websock.close() crapcleaner = re.compile("0\n") NoCrapChanStr = crapcleaner.sub('', ChanData) Channels = NoCrapChanStr.split(';') NoWhiteSpaceChannelStr = spacecleaner.sub('%20', NoCrapChanStr) URLReadyChannels = NoWhiteSpaceChannelStr.split(';') global NoWhiteSpaceChannels NoWhiteSpaceChannels = NoWhiteSpaceChannelStr.split(';') self.scaleX = ( float(self.getWidth()) / float(720) ) self.scaleY = ( float(self.getHeight()) / float(576) ) self.strActionInfo = xbmcgui.ControlLabel(100, 120, 200, 200, '', 'font13', '0xFFFF00FF') self.addControl(self.strActionInfo) self.strActionInfo.setLabel('Push BACK to quit') self.ChanObjList = xbmcgui.ControlList(int(185 * self.scaleX),int(160 * self.scaleY), int(490 * self.scaleX), int(365 * self.scaleY)) self.addControl(self.ChanObjList) for Channel in Channels: if len(Channel) > 0: self.ChanObjList.addItem(Channel) self.setFocus(self.ChanObjList) def onAction(self, action): if action == ACTION_PREVIOUS_MENU: self.close() WebSock = urllib.urlopen(TVStop) WebSock.close() def onControl(self, control): if control == self.ChanObjList: blah = xbmcgui.Dialog() ArrayPtr = self.ChanObjList.getSelectedPosition() StartChannelURL = TVStart + NoWhiteSpaceChannels[ArrayPtr] WebSock = urllib.urlopen(TVStop) WebSock.close() WebSock = urllib.urlopen(StartChannelURL) WebSock.close() xbmc.Player().play(TVStream) JTVLANClient = JTVLANClientObj() JTVLANClient .doModal() del JTVLANClient