def update(): #download ZIP file start = time.clock() localfile = ROOT_DIR+"/update.zip" response = urllib2.urlopen(REMOTE_FILE_XML) html = response.read() remote_file = common.parseDOM(html,"file")[0].encode("utf-8") #remote version downloadtools.downloadfile(remote_file, localfile, notStop=False) end = time.clock() logger.info("org.harddevelop.kodi.tv Downloaded in %d seconds " % (end-start+1)) separatorChar = XBMCUtils.getSeparatorChar() #unzip unzipper = ziptools.ziptools() logger.info("org.harddevelop.kodi.tv destpathname=%s" % ROOT_DIR) addons_dir = XBMCUtils.getAddonsDir() current_plugin_dir = XBMCUtils.getPathFixedFrom(XBMCUtils.getAddonInfo('path')) logger.debug("using dir: "+addons_dir+" to extract content") unzipper.extractReplacingMainFolder(localfile,addons_dir,current_plugin_dir) #github issues #unzipper.extract(localfile,ROOT_DIR) #clean downloaded zip file logger.info("org.harddevelop.kodi.tv clean zip file...") os.remove(localfile) logger.info("org.harddevelop.kodi.tv clean done!")
def applyFix(fileFix, removeFix, replaced=''): logger.debug("Applying fix...") ROOT_DIR = XBMCUtils.getAddonInfo('path') # Read in the file pythonScript = ROOT_DIR + fileFix with open(pythonScript, 'r') as file: filedata = file.read() # Replace the target string filedata = filedata.replace(removeFix, replaced) # Write the file out again with open(pythonScript, 'w') as file: file.write(filedata)
def importEngine(engine, url, targetPath, deletePath): ROOT_DIR = XBMCUtils.getAddonInfo('path') try: shutil.rmtree(ROOT_DIR + "/" + engine) except: logger.debug("local folder %s doesn't exists... continue" % str(ROOT_DIR + "/" + engine)) pass logger.debug("downloading...") localfile = ROOT_DIR + "/master.zip" try: os.delete(localfile) except: logger.debug("local file doesn't exists... continue") pass downloadtools.downloadfile(url, localfile, notStop=True) logger.debug("done, unzipping...") logger.debug("Download done, now it's time to unzip") unzipper = ziptools.ziptools() unzipper.extract(localfile, ROOT_DIR) shutil.move(ROOT_DIR + targetPath, ROOT_DIR + "/" + engine) logger.debug("done, delete all unused files...") shutil.rmtree(ROOT_DIR + "/" + deletePath) logger.debug("Unzip done! cleaning...") try: os.unlink(localfile) except: logger.debug("couldn't remove %s" % localfile) pass logger.info("Additional addon clean done!")
import xbmcgui import xbmc import xbmcaddon import json import sys from PIL import Image from tvboxcore.xbmcutils import XBMCUtils from tvboxcore.downloadtools import downloadfile from tvboxcore import logger ROOT_DIR = XBMCUtils.getAddonInfo('path') class windowImage(xbmcgui.WindowDialog): def __init__(self): window = xbmcgui.Window(xbmcgui.getCurrentWindowId()) window.setProperty('ShowImage', 'true') # check arg getting from settings try: idImage = str(sys.argv[1]) except: idImage = '0' window = xbmcgui.Window(xbmcgui.getCurrentWindowId()) imagePath = window.getProperty('imagePath') logger.debug("imagePath property: " + str(imagePath)) # set max height and margin to background xImageRes = 660