def sudo(inst): global sudoC sudoC.depth += 1 run(inst) sudoC.depth -= 1
titles, urls, thumbs, bgs = data.get_seasons(arg) if len(titles) == 1: return plugin.redirect(urls[0]) view(titles, urls, thumbs=thumbs, bgs=bgs) @plugin.route('/program/Episodes/<series_id>/<path:season_id>') def episodes(series_id, season_id): import data view(*data.get_episodes(series_id, season_id)) @plugin.route('/serie/<series_id>/<video_id>/.*') @plugin.route('/program/<video_id>') @plugin.route('/program/<video_id>/.*') def play(video_id, series_id=""): import data, subs url = data.get_media_url(video_id) xbmcplugin.setResolvedUrl(plugin.handle, True, ListItem(path=url)) player = xbmc.Player() subtitle = subs.get_subtitles(video_id) if subtitle: #Wait for stream to start start_time = time.time() while not player.isPlaying() and time.time() - start_time < 10: time.sleep(1.) player.setSubtitles(subtitle) if not SHOW_SUBS: player.showSubtitles(False) if __name__ == '__main__': plugin.run()
from resources.lib import context <%_ } else if (props.type == 'Plugin') { -%> from resources.lib import plugin <%_ } else if (props.type == 'Script') { -%> from resources.lib import script <%_ } else if (props.type == 'Service') { -%> from resources.lib import service <%_ } else if (props.type == 'Subtitle') { -%> from resources.lib import subtitle <% } %> import logging import xbmcaddon # Keep this file to a minimum, as Kodi # doesn't keep a compiled copy of this ADDON = xbmcaddon.Addon() kodilogging.config() <%_ if (props.type == 'Contextmenu') { -%> context.run() <%_ } else if (props.type == 'Plugin') { -%> plugin.run() <%_ } else if (props.type == 'Script') { -%> script.show_dialog() <%_ } else if (props.type == 'Service') { -%> service.run() <%_ } else if (props.type == 'Subtitle') { -%> subtitle.run() <% } %>
import os import plugin import config from bot import bot from webserver import server plugin.run() if __name__ == '__main__': if config.local_run: bot.polling(none_stop=True) else: server.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
def run_file(s): f = open(s) for inst in f: run(inst)
#!/usr/bin/python import sys, json, os input = json.loads(sys.argv[1]) os.chdir(input['pluginPath']) sys.path.insert(0, input['pluginPath']) sys.path.append(input['builtinModulesPath']) import plugin plugin.run(*input['runArgs'])
def runImportExport(self): #Thanks to below line for line 584 and on... # http://americiumdream.wordpress.com/cyb-dev/commented-pyqt-code-for-main-windows/ action = self.sender() importDir = "" if isinstance(action, QtGui.QAction): #(paranoid sanity check) # the menu item's data is the filename we need: importDir = unicode(action.data().toString()) else: return config = ConfigParser.RawConfigParser() config.read('./%s/plugin.ini'%importDir) name = config.get('SQBL Plugin',"Name") filetypes = config.get('SQBL Plugin',"Extensions") bf = config.get('SQBL Plugin',"Base File") extension = bf.rsplit('.',1)[-1].lower() runType = config.get('SQBL Plugin',"Type").lower() if runType not in ["import","export"]: return #not an importer or exporter, so bail. TODO: Maybe an error? if extension in ['xsl','xslt']: if runType == "import": filename = QtGui.QFileDialog.getOpenFileName( self, 'Import - %s'%name, '.', filetypes ) elif runType == "export": filename = QtGui.QFileDialog.getSaveFileName( self, 'Export - %s'%name, '.', filetypes ) if not filename: return #User hit cancel, so bail if runType == "import": with open(filename,"r") as f: xml = etree.parse(f) elif runType == "export": xml = etree.fromstring(self.model.getXMLstring()) with open("./%s/%s"%(importDir,bf)) as f: parser = etree.XMLParser(recover=True) xslt = etree.parse(f,parser) transform = etree.XSLT(xslt) out = unicode(transform(xml)) if runType == "import": self.open(out) elif runType == "export": with open(filename,"w") as f: f.write(out) if extension in ['py']: sys.path.append('./%s/'%importDir) import plugin import imp plugin = imp.load_source(bf.rsplit(".",1)[0],'./%s/%s'%(importDir,bf)) try: result = plugin.run('World') except Exception as err: import traceback blame = config.get('SQBL Plugin',"Author") exc_type, exc_value = sys.exc_info()[:2] errorMsg = "\n".join([ "<b>'%s' encountered an error while running.</b>" % name, "If this occurs again, contact the plugin author", " - %s" % blame, "", "The error is included below:", "", ]) + traceback.format_exc(limit=3) #eption(exc_type, exc_value, exc_traceback,limit=3) errorMsg = errorMsg.replace("\n","<br>") QtGui.QMessageBox.critical(self, "An error occured while running the plugin", errorMsg )
<%_ if (props.type == 'Contextmenu') { -%> from resources.lib import context <%_ } else if (props.type == 'Plugin') { -%> from resources.lib import plugin <%_ } else if (props.type == 'Script') { -%> from resources.lib import script <%_ } else if (props.type == 'Service') { -%> from resources.lib import service <%_ } else if (props.type == 'Subtitle') { -%> from resources.lib import subtitle <% } %> import xbmcaddon # Keep this file to a minimum, as Kodi # doesn't keep a compiled copy of this ADDON = xbmcaddon.Addon() kodilogging.config() <%_ if (props.type == 'Contextmenu') { -%> context.run() <%_ } else if (props.type == 'Plugin') { -%> plugin.run(argv=sys.argv) <%_ } else if (props.type == 'Script') { -%> script.show_dialog() <%_ } else if (props.type == 'Service') { -%> service.run() <%_ } else if (props.type == 'Subtitle') { -%> subtitle.run() <% } %>