From: Nicolas Boisselier Date: Wed, 17 Apr 2019 11:05:56 +0000 (+0100) Subject: default.py X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=cd55b25d73a7fddaaf0b6e168e0d3e0be056c061;p=plugin.video.news.nbdom.net.git default.py --- diff --git a/default.py b/default.py old mode 100644 new mode 100755 index e825a01..b250f7d --- a/default.py +++ b/default.py @@ -1,9 +1,64 @@ +#!/usr/bin/env python +# # See: https://kodi.wiki/view/Audio-video_add-on_tutorial +# + import sys import xbmcgui import xbmcplugin import urllib,urllib2,re +def getUrl(url): + req = urllib2.Request(url) + req.add_header('User-Agent', 'Kodi') + response = urllib2.urlopen(req) + content = response.read() + response.close() + return content + +def getParams(): + param=[] + paramstring=sys.argv[2] + + if len(paramstring)>=2: + params=sys.argv[2] + cleanedparams=params.replace('?','') + + if (params[len(params)-1]=='/'): + params=params[0:len(params)-2] + + pairsofparams=cleanedparams.split('&') + param={} + + for i in range(len(pairsofparams)): + splitparams={} + splitparams=pairsofparams[i].split('=') + if (len(splitparams))==2: + param[splitparams[0]]=splitparams[1] + + return param + +def addLink(name,url,iconimage): + ok=True + liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage) + liz.setInfo( type="Video", infoLabels={ "Title": name } ) + ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz) + return ok + +def addDir(name,url,mode,iconimage,description): + u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name) + ok=True + liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage) + liz.setInfo( type="Video", infoLabels={ "Title": name , "Plot": description} ) + ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True) + return ok + +# +# Main +# +if True: + sys.exit(0) + addon_handle = int(sys.argv[1]) xbmcplugin.setContent(addon_handle, 'movies') @@ -14,10 +69,3 @@ xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) -def getUrl(url): - req = urllib2.Request(url) - req.add_header('User-Agent', 'Kodi') - response = urllib2.urlopen(req) - content = response.read() - response.close() - return content