2011-01-22, 22:49
How i write my own plugin
1. create a file under plugin.video.xstream\sites (eg. test.py)
2. write this code:
3. done!
when your start xbmc, do you see under xStream the follow entry: "test.py"
a example with more code: (play megavideo file and search by google)
greetz
_murphy_
1. create a file under plugin.video.xstream\sites (eg. test.py)
2. write this code:
PHP Code:
SITE_IDENTIFIER = 'test'
SITE_NAME = 'MyTest'
def load():
oGui = cGui()
oGui.setEndOfDirectory()
when your start xbmc, do you see under xStream the follow entry: "test.py"
a example with more code: (play megavideo file and search by google)
PHP Code:
from resources.lib.handler.outputParameterHandler import cOutputParameterHandler
from resources.lib.handler.inputParameterHandler import cInputParameterHandler
from resources.lib.parser import cParser
from resources.lib.handler.requestHandler import cRequestHandler
from resources.lib.gui.guiElement import cGuiElement
from resources.lib.gui.gui import cGui
from resources.lib.gui.hoster import cHosterGui
from resources.lib.handler.hosterHandler import cHosterHandler
from resources.lib.util import cUtil
# filename
SITE_IDENTIFIER = 'test'
# displayname
SITE_NAME = 'MyTest'
# start method of plugin
def load():
oGui = cGui()
# create GuiElement
oGuiElement = cGuiElement()
oGuiElement.setSiteName(SITE_IDENTIFIER)
oGuiElement.setFunction('showSearchGui')
oGuiElement.setTitle('Google Suche')
oGui.addFolder(oGuiElement)
# create GuiElement with Paramaters for next Function
oGuiElement = cGuiElement()
oGuiElement.setSiteName(SITE_IDENTIFIER)
oGuiElement.setFunction('playMegaVideo')
oGuiElement.setTitle('spiele ein MegaVideo Video ab')
oOutputParameterHandler = cOutputParameterHandler()
oOutputParameterHandler.addParameter('sMegaVideoUrl', 'http://megavideo.com/?v=GVDI49ZF')
oGui.addFolder(oGuiElement, oOutputParameterHandler)
oGui.setEndOfDirectory()
def showSearchGui():
oGui = cGui()
# show KeyBoard
sSearchText = oGui.showKeyBoard()
if (sSearchText != False):
__search(sSearchText)
return
oGui.setEndOfDirectory()
def __search(sSearchText):
oGui = cGui()
# create Request
oRequestHandler = cRequestHandler('http://www.google.de/search')
oRequestHandler.addParameters('hl', 'de')
oRequestHandler.addParameters('source', 'hp')
oRequestHandler.addParameters('q', sSearchText)
sHtmlContent = oRequestHandler.request()
# create Pattern
sPattern = '<h3 class="r"><a href="([^"]+)".*?>(.*?)</a></h3>'
oParser = cParser()
aResult = oParser.parse(sHtmlContent, sPattern)
if (aResult[0] == True):
for aEntry in aResult[1]:
oGuiElement = cGuiElement()
oGuiElement.setSiteName(SITE_IDENTIFIER)
oGuiElement.setFunction('dummyFolder')
oGuiElement.setTitle(cUtil().removeHtmlTags(str(aEntry[1])))
oGui.addFolder(oGuiElement)
oGui.setEndOfDirectory()
def playMegaVideo():
oGui = cGui()
# get Input Paramater
oInputParameterHandler = cInputParameterHandler()
if (oInputParameterHandler.exist('sMegaVideoUrl')):
sMegaVideoUrl = oInputParameterHandler.getValue('sMegaVideoUrl')
# load Hoster and show HosterMenu
oHoster = cHosterHandler().getHoster('megavideo')
cHosterGui().showHoster(oGui, oHoster, sMegaVideoUrl)
oGui.setEndOfDirectory()
def dummyFolder():
oGui = cGui()
oGui.setEndOfDirectory()
greetz
_murphy_