2017-02-22, 12:32
Skin Editor
by Skin Headz
somebody else can pick this up
SCRIPT TO MOVE A SKIN ITEM
by Skin Headz
somebody else can pick this up
SCRIPT TO MOVE A SKIN ITEM
PHP Code:
import xbmcgui,sys,os,xbmc
from xml.etree import ElementTree as et
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
ACTION_BACKSPACE = 92
ACTION_MOVE_RIGHT = 2
ACTION_MOVE_LEFT = 1
BAR_FROM_TOP = ".//*[@name='SkinHeadzBarTop']/top"
BAR_HEIGHT = ".//*[@name='SkinHeadzBarHeight']/height"
BAR_WIDTH = ".//*[@name='SkinHeadzBarWidth']/width"
SUB_BAR_TOP = ".//*[@name='SkinHeadzSubBarTop']/top"
class WindowXMLDialog(xbmcgui.WindowXMLDialog):
def onInit(self):
#Put list populating code/GUI startup things here
self.window = xbmcgui.Window(13000)
self.SkinHeadz = xbmc.translatePath('special://skin/1080i/includes_Demon.xml')
self.tree = et.parse(self.SkinHeadz)
self.slider = self.getControl( 9119 )
self.sliderperc = self.slider.getPercent()
self.refBar = self.getControl( 9120 )
self.text = self.getControl( 9121 )
self.text.setLabel('SET POSITION')
self.refBar.setHeight(int(self.tree.find(".//*[@name='SkinHeadzBarHeight']/height").text))
self.slider.setPercent(self.pixeltopercent(int(self.tree.find('.//top').text)))
self.refBar.setPosition(0,int(self.tree.find('.//top').text))
self.refBar.setWidth(int(self.tree.find(".//*[@name='SkinHeadzBarWidth']/width").text))
def pixeltopercent(self,pixel):
return int(pixel * 100 / 1080)
def pixeltopercent1920(self,pixel):
return int(pixel * 100 / 1920)
def percenttopixel(self,percent):
return int(percent * 1080 / 100)
def percenttopixel920(self,percent):
return int(percent * 1920 / 100)
def setHeight(self):
self.currentHeight = self.tree.find(BAR_HEIGHT).text
self.slider.setPercent(self.pixeltopercent(self.currentHeight))
self.text.setLabel('SET HEIGHT')
self.refBar.setHeight(self.percenttopixel(self.sliderperc))
def setElement(self,percent,element):
if element == SUB_BAR_TOP:
self.pixels = str(int(percent * 1080 / 100))
self.tree.find(element).text = self.pixels
self.tree.write(self.SkinHeadz)
else:
self.pixels = str(int(percent * 1080 / 100))
self.tree.find(element).text = self.pixels
self.tree.write(self.SkinHeadz)
if element == BAR_FROM_TOP:
self.slider.setPercent(self.pixeltopercent(int(self.tree.find(BAR_HEIGHT).text)))
#elif element == BAR_HEIGHT : xbmc.executebuiltin('ReloadSkin()')
elif element == BAR_HEIGHT:
xbmc.executebuiltin('ReloadSkin()')
def bar(self,attrib):
if 'osition' in attrib: self.refBar.setPosition(0,self.percenttopixel(self.slider.getPercent()))
elif 'eight' in attrib: self.refBar.setHeight(self.percenttopixel(self.slider.getPercent()))
def onAction(self, action):
if action == ACTION_BACKSPACE:self.close()
elif action == ACTION_SELECT_ITEM:
if "POSITION" in self.text.getLabel():
self.setElement(self.slider.getPercent(),BAR_FROM_TOP)
self.text.setLabel('SET HEIGHT')
elif "HEIGHT" in self.text.getLabel():
self.setElement(self.slider.getPercent(),BAR_HEIGHT)
self.setElement(self.slider.getPercent(),SUB_BAR_TOP)
self.text.setLabel('SET WIDTH')
elif "WIDTH" in self.text.getLabel():
self.setElement(self.slider.getPercent(),BAR_WIDTH)
elif action == ACTION_MOVE_LEFT:
if "POSITION" in self.text.getLabel(): self.bar("position")
elif "HEIGHT" in self.text.getLabel(): self.bar("height")
elif "WIDTH" in self.text.getLabel(): self.bar("width")
elif action == ACTION_MOVE_RIGHT:
if "POSITION" in self.text.getLabel(): self.bar("position")
elif "HEIGHT" in self.text.getLabel(): self.bar("height")
elif "WIDTH" in self.text.getLabel(): self.bar("width")
def onClick(self,controlID):
if controlID == 9119: pass
#self.getControl( 9120 ).setPosition(0,int(self.slider.getPercent()))
def onFocus(self,controlID):
pass
if __name__ == "__main__":
scriptDir = xbmc.translatePath('special://skin/')
sys.path.insert(0, os.path.join(scriptDir,'1080i'))
w = WindowXMLDialog("Custom_Resize.xml", scriptDir)
w.doModal()
del w
includes_Demon
PHP Code:
<includes>
<include name="SkinHeadzBarTop">
<top>10</top>
</include>
<include name="SkinHeadzBarHeight">
<height>162</height>
</include>
<include name="SkinHeadzSubBarTop">
<top>162</top>
</include>
<include name="SkinHeadzBarWidth">
<width>2210</width>
</include>
<include name="SkinHeadzSideLeft">
<width>750</width>
<left>-53</left>
</include>
<include name="SkinHeadzSideRight">
<width>750</width>
<left>52</left>
</include>
<include name="SkinHeadzSideGap">
<itemgap>960</itemgap>
</include>
</includes>
Heres the library i used with it
PHP Code:
import xbmc,xbmcaddon,xbmcgui,urllib2,base64,shutil,re,fileinput
import errno,json,os,hashlib,sys,urllib,xbmcplugin,time
def show(string):
return base64.b64decode(b'%s'%string)
def hide(string):
return base64.b64encode(b'%s'%string)
def exe(string):
xbmc.executebuiltin(string)
def updateaddons():
exe('UpdateLocalAddons')
def reloadkeymaps():
exe('Action(reloadkeymaps)')
def window(window):
exe('ActivateWindow(%s)'%window)
def pvr(toggle):
jsonGetPVR = '{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"}, "id":1}'
jsonSetPVR = '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.enabled", "value":%s},"id":1}'
jsonNotify = '{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"PVR", "message":"%s","image":""}, "id":1}'
PVR = json.loads(xbmc.executeJSONRPC(jsonGetPVR))['result']['value']
if toggle:
if (PVR == False):
xbmc.executeJSONRPC(jsonSetPVR % "true")
xbmc.executeJSONRPC(jsonNotify % "Live TV Enabled")
else: pass
else:
if PVR: # i may not want to disable at all. there may be no need
xbmc.executeJSONRPC(jsonSetPVR % "false")
xbmc.executeJSONRPC(jsonNotify % "Live TV Disabled")
def download(url, dest, dp = None):
if not dp:
dp = xbmcgui.DialogProgress()
dp.create(addon('id'),"Downloading Content",' ', ' ')
dp.update(0)
start_time=time.time()
urllib.urlretrieve(url, dest, lambda nb, bs, fs: _pbhook(nb, bs, fs, dp, start_time))
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
try:
percent = min(numblocks * blocksize * 100 / filesize, 100)
currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
kbps_speed = numblocks * blocksize / (time.time() - start_time)
if kbps_speed > 0 and not percent == 100:
eta = (filesize - numblocks * blocksize) / kbps_speed
else:
eta = 0
kbps_speed = kbps_speed / 1024
type_speed = 'KB'
if kbps_speed >= 1024:
kbps_speed = kbps_speed / 1024
type_speed = 'MB'
total = float(filesize) / (1024 * 1024)
mbs = '[COLOR red][B]Size:[/B] [COLOR green]%.02f[/COLOR] MB of [COLOR green]%.02f[/COLOR] MB[/COLOR]'%(currently_downloaded, total)
e = '[COLOR red][B]Speed:[/B] [COLOR green]%.02f [/COLOR]%s/s ' % (kbps_speed, type_speed)
e += '[B]ETA:[/B] [COLOR green]%02d:%02d[/COLOR][/COLOR]' % divmod(eta, 60)
dp.update(percent, '', mbs, e)
except Exception, e:
return str(e)
if dp.iscanceled():
dp.close()
sys.exit()
def forceclose(name="This Function"):
if choice('In Order To Enable %s, You Must Force Close'%(name),"Force Close","Later"): os._exit(1)
def read(file):
return open(file, 'r').read()
def search(query,file):
return re.findall(query,file)
def action(string):
exe('Action(%s)'%(string))
def info(string):
return xbmc.getInfoLabel(string)
def refreshContainer():
exe('Container.Refresh')
def updateContainer():
exe('Container.Update')
def startpvr():
exe('StartPVRManager')
def controlMessage(control):
exe('Control.Message(%s)')%(control)
def RunAddon(id):
exe('RunAddon(%s)')%(id)
def RunPlugin(id):
exe('RunPlugin(%s)')%(id)
def condition(string):
return xbmc.getCondVisibility(string)
def enableaddon(id,enable='true'):
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "%s", "enabled": "%s" }}'%(id,enable))
def hasaddon(addon):
try:
if xbmcaddon.Addon(addon): return True
except: return False
def copy(src, dst):
try:
shutil.copytree(src, dst)
except OSError as exc: # python >2.5
if exc.errno == errno.ENOTDIR:
shutil.copy(src, dst)
else: raise
def addon(item,id="skin.aeon.nox.silvo.skinheadz"):
try:
if item == 'id' : return xbmcaddon.Addon(id).getAddonInfo('id')
elif item == 'name' : return xbmcaddon.Addon(id).getAddonInfo('name')
elif item == 'path' : return xbmcaddon.Addon(id).getAddonInfo('path')
elif item == 'icon' : return xbmcaddon.Addon(id).getAddonInfo('icon')
elif item == 'fanart' : return xbmcaddon.Addon(id).getAddonInfo('fanart')
elif item == 'author' : return xbmcaddon.Addon(id).getAddonInfo('author')
elif item == 'fanart' : return xbmcaddon.Addon(id).getAddonInfo('fanart')
elif item == 'version' : return xbmcaddon.Addon(id).getAddonInfo('version')
elif item == 'summary' : return xbmcaddon.Addon(id).getAddonInfo('summary')
elif item == 'description' : return xbmcaddon.Addon(id).getAddonInfo('description')
except: return False
def data(string):
return json.loads(string)
def openURL(url):
req = urllib2.Request(url)
req.add_header('User-Agent', addon('id'))
response = urllib2.urlopen(req)
link=response.read()
response.close()
return link
def notification(message,title=addon('name')):
xbmcgui.Dialog().notification(title,message)
def ok(line1,line2=None,line3=None,title=addon('name')):
xbmcgui.Dialog().ok(title, line1=line1,line2=line2,line3=line3)
def choice(string,y='YES',n='NO',title=addon('name')):
return xbmcgui.Dialog().yesno(title,string,yeslabel=y,nolabel=n)
def input(heading=addon('name')):
return xbmcgui.Dialog().input(heading, type=xbmcgui.INPUT_ALPHANUM)
def cut(string):
exec(string)
def log(string):
xbmc.log(string)
def setting(id,value=None,addon=addon('id')):
if not value : return xbmcaddon.Addon(addon).getSetting(id)
else : return xbmcaddon.Addon(addon).setSetting(id,value)
def insertline(file,search,add):
includes = []
for line in fileinput.FileInput(file,inplace=1):
if search in line:
line=line.replace(line,line+add)
includes.append(line)
with open(file, "a") as myfile:
for line in includes:
myfile.write(line)
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
def addItemGUI(conrol,label1=None,label2=None,icon=None,thumb=None):
self.self.window.getControl(control).addItem(xbmcgui.ListItem(label1, label2=url, iconImage=icon, thumbnailImage=thumb))
def addDir(display, mode=None,username=None,password=None,icon=addon(show('aWNvbg==')),description=addon(show('aWQ='))):
u = sys.argv[0]
if not mode == None: u += show("P21vZGU9JXM=") % urllib.quote_plus(mode)
ok=True
liz=xbmcgui.ListItem(display, iconImage=show("RGVmYXVsdEZvbGRlci5wbmc="), thumbnailImage=icon)
liz.setInfo( type="Video", infoLabels={ show("VGl0bGU="): display, show("UGxvdA=="): description} )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def addItem(display, mode=None,username=None,password=None,icon=addon(show('aWNvbg==')),description=addon(show('aWQ='))):
u = sys.argv[0]
if not mode == None: u += show("P21vZGU9JXM=") % urllib.quote_plus(mode)
ok=True
liz=xbmcgui.ListItem(display, iconImage=show("RGVmYXVsdEZvbGRlci5wbmc="), thumbnailImage=icon)
liz.setInfo( type="Video", infoLabels={ show("VGl0bGU="): display, show("UGxvdA=="): description} )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz)
return ok
def skinres():
results = search(r'aspect="(.+?)" .+? folder="(.+?)"',read(xbmc.translatePath('special://skin/addon.xml')))
for item in results:
if info('Skin.AspectRatio') in item:
for listitem in item:
if not info('Skin.AspectRatio') in listitem:
xbmc.log(listitem)
return listitem
def get(path,file=None):
if 'ystem' in path: return xbmc.translatePath('special://xbmc/'+file) if file else xbmc.translatePath('special://xbmc/')
elif 'ome' in path: return xbmc.translatePath('special://home/'+file) if file else xbmc.translatePath('special://home/')
elif 'ddons' in path: return xbmc.translatePath('special://home/addons/'+file) if file else xbmc.translatePath('special://home/addons/')
elif 'serdata' in path: return xbmc.translatePath('special://userdata/'+file) if file else xbmc.translatePath('special://userdata/')
elif 'atabase' in path: return xbmc.translatePath('special://userdata/Database/'+file) if file else xbmc.translatePath('special://userdata/Database/')
elif 'eymaps' in path: return xbmc.translatePath('special://userdata/keymaps/'+file) if file else xbmc.translatePath('special://userdata/keymaps/')
elif 'ddon' in path and 'ata' in path: return xbmc.translatePath('special://userdata/addon_data/'+file) if file else xbmc.translatePath('special://userdata/addon_data')
elif 'lugin.' in path: return xbmc.translatePath('special://home/addons/'+path+"/"+file) if file else xbmc.translatePath('special://home/addons/%s/'%path)
elif 'cript.' in path: return xbmc.translatePath('special://home/addons/'+path+"/"+file) if file else xbmc.translatePath('special://home/addons/%s/'%path)
elif 'kin' in path and 'addon.xml' in file:return xbmc.translatePath('special://skin/%s'%(file))
elif 'kin' in path and 'debug' in file: return xbmc.translatePath('special://skin/media/%s'%(file))
elif 'kin' in path: return xbmc.translatePath('special://skin/%s/%s'%(skinres(),file)) if file else xbmc.translatePath('special://skin/')
just activate the home window before you runscript and if your trying to do this from android for any odd reason, youll need to impliment the python 2.7 version of elementtree
hope somebody elses imagination is intrigued