예제 #1
0
def get_skin_view(ctype):
	xmls={"video":"MyVideoNav.xml","audio":"MyMusicNav.xml","image":"MyPics.xml"}
	res=dom.read(path.join(kodi_sdir,"addon.xml"))
	dir=res.getElementsByTagName("res")[0].getAttribute("folder")
	res.unlink()
	navxml=path.join(kodi_sdir,dir,xmls[ctype])
	res=dom.read(navxml)
	views=res.getElementsByTagName("views")[0].lastChild.data.split(",")
	res.unlink()
	for view in views:
		label=xbmc.getInfoLabel("Control.GetLabel(%s)"%view)
		if not (label == '' or label == None): break
	return xbmc.getSkinDir(),view
예제 #2
0
def add(isFolder, content_type, name, thumb, uri):
    p, cat, module, page, args, info, art = decode(uri)
    if opath.exists(kodi_favxml):
        res = dom.read(kodi_favxml)
    else:
        res = minidom.parseString("<favourites></favourites>")
    favs = res.getElementsByTagName("favourites")[0]
    newnode = res.createElement("favourite")
    newnode.setAttribute("name", name)
    newnode.setAttribute("thumb", thumb)
    link = "plugin://plugin.program.ump/?%s" % urlencode(
        {
            "module": module,
            "page": page,
            "args": json.dumps(args).encode("base64"),
            "info": json.dumps(info).encode("base64"),
            "art": json.dumps(art).encode("base64"),
            "content_type": content_type
        })
    if isFolder:
        str = 'ActivateWindow(%d,"%s",return)' % (WID[content_type], link)
    else:
        str = 'RunPlugin("%s")' % link
    favs.appendChild(newnode)
    newnode.appendChild(res.createTextNode(str))
    dom.write(kodi_favxml, res)
    dialog = xbmcgui.Dialog()
    dialog.ok('UMP', '%s added to bookmarks' % name)
예제 #3
0
def load():
    favs = []

    if opath.exists(kodi_favxml):
        res = dom.read(kodi_favxml)
    else:
        return None, favs
    for fav in res.getElementsByTagName("favourite"):
        cmd = None
        data = fav.lastChild.data.replace("&quot;", '"')
        cmd1 = findall('RunPlugin\((.*?)"\)', data)
        cmd2 = findall('PlayMedia\((.*?)"\)', data)
        cmd3 = findall('ActivateWindow\(([0-9]*?)\,(.*?)"\,', data)
        if len(cmd1):
            cmd = cmd1[0]
            wid = None
        if len(cmd2):
            cmd = cmd2[0]
            wid = None
        elif len(cmd3):
            wid, cmd = cmd3[0]
        if not cmd is None:
            path, cat, module, page, args, info, art = decode(cmd)
            if not "plugin.program.ump" in path:
                continue
            name = fav.getAttribute("name").encode("utf-8")
            thumb = fav.getAttribute("thumb").encode("utf-8")
            favs.append(
                (wid, name, thumb, data, cat, module, page, args, info, art))
    return res, favs
예제 #4
0
def load():
	favs=[]
	
	if opath.exists(kodi_favxml):
		res=dom.read(kodi_favxml)
	else:
		return None,favs
	for fav in res.getElementsByTagName("favourite"):
		cmd=None
		data=fav.lastChild.data.replace("&quot;",'"')
		cmd1=findall('RunPlugin\((.*?)"\)',data)
		cmd2=findall('PlayMedia\((.*?)"\)',data)
		cmd3=findall('ActivateWindow\(([0-9]*?)\,(.*?)"\,',data)
		if len(cmd1):
			cmd=cmd1[0]
			wid=None
		if len(cmd2):
			cmd=cmd2[0]
			wid=None
		elif len(cmd3):
			wid,cmd=cmd3[0]
		if not cmd is None:
			path,cat,module,page,args,info,art=decode(cmd)
			if not "plugin.program.ump" in path:
				continue
			name=fav.getAttribute("name").encode("utf-8")
			thumb=fav.getAttribute("thumb").encode("utf-8")
			favs.append((wid,name,thumb,data,cat,module,page,args,info,art))
	return res,favs
예제 #5
0
def settingsActive(sets):
	res=dom.read(addon_setxml)
	actives=[]
	for set in sets:
		for setting in res.getElementsByTagName("setting"):
			if setting.getAttribute("id") == set and not setting.getAttribute("visible").lower()=="false":
				actives.append(set)
				break
	res.unlink()
	return actives
예제 #6
0
def set_setting_attrs(attrs):
	ret=False
	res=dom.read(addon_setxml)
	for name,set,val in attrs:
		for setting in res.getElementsByTagName("setting"):
			if setting.getAttribute("id") == name:
				setting.setAttribute(set,val)
				ret=True
				break
	if ret:
		dom.write(addon_setxml,res)
	return ret
예제 #7
0
def getsocket():
	gen_set=None
	try:
		gen_set=dom.read(kodi_guixml)
		if not get_set(gen_set,"usehttpproxy").lower() == "false":
			s=[3,1,1,2,2][int(get_set(gen_set,"httpproxytype"))]
			socks.setdefaultproxy(s, get_set(gen_set,"httpproxyserver"), int(get_set(gen_set,"httpproxyport")),int(get_set(gen_set,"httpproxytype"))==4,get_set(gen_set,"httpproxyusername"),get_set(gen_set,"httpproxypassword"))
			ret= socks.socksocket
		else:
			ret= socket
	except:
		ret= socket
	if gen_set:
		gen_set.unlink()
	return ret
예제 #8
0
def force(mode):
	mode=str(mode)
	if path.exists(setxml):
		res=dom.read(setxml)
		adv=getchild(res,res,"advancedsettings")
		nw=getchild(res,adv,"network")
		bm=getchild(res,nw,"buffermode")
		for text in bm.childNodes:
			bm.removeChild(text)
		bm.appendChild(res.createTextNode(mode))
	else:
		res=minidom.parseString("<advancedsettings><network><buffermode>%s</buffermode></network></advancedsettings>"%mode)
	dom.write(setxml,res)
	dialog = Dialog()
	dialog.ok('UMP', 'LibCurl Buffering Mode set to %s'%mode,logs[mode],"YOU NEED TO RESTART KODI TO CHANGES TAKE AFFECT")
예제 #9
0
def force(mode):
    mode = str(mode)
    if path.exists(setxml):
        res = dom.read(setxml)
        adv = getchild(res, res, "advancedsettings")
        nw = getchild(res, adv, "network")
        bm = getchild(res, nw, "buffermode")
        for text in bm.childNodes:
            bm.removeChild(text)
        bm.appendChild(res.createTextNode(mode))
    else:
        res = minidom.parseString(
            "<advancedsettings><network><buffermode>%s</buffermode></network></advancedsettings>"
            % mode)
    dom.write(setxml, res)
    dialog = Dialog()
    dialog.ok('UMP', 'LibCurl Buffering Mode set to %s' % mode, logs[mode],
              "YOU NEED TO RESTART KODI TO CHANGES TAKE AFFECT")
예제 #10
0
def getsocket():
    gen_set = None
    try:
        gen_set = dom.read(kodi_guixml)
        if not get_set(gen_set, "usehttpproxy").lower() == "false":
            s = [3, 1, 1, 2, 2][int(get_set(gen_set, "httpproxytype"))]
            socks.setdefaultproxy(s, get_set(gen_set, "httpproxyserver"),
                                  int(get_set(gen_set, "httpproxyport")),
                                  int(get_set(gen_set, "httpproxytype")) == 4,
                                  get_set(gen_set, "httpproxyusername"),
                                  get_set(gen_set, "httpproxypassword"))
            ret = socks.socksocket
        else:
            ret = socket
    except:
        ret = socket
    if gen_set:
        gen_set.unlink()
    return ret
예제 #11
0
def add(isFolder,content_type,name,thumb,uri):
	p,cat,module,page,args,info,art=decode(uri)
	if opath.exists(kodi_favxml):
		res=dom.read(kodi_favxml)
	else:
		res=minidom.parseString("<favourites></favourites>")
	favs=res.getElementsByTagName("favourites")[0]
	newnode = res.createElement("favourite")
	newnode.setAttribute("name", name)
	newnode.setAttribute("thumb", thumb)
	link="plugin://plugin.program.ump/?%s"%urlencode({"module":module,"page":page,"args":json.dumps(args).encode("base64"),"info":json.dumps(info).encode("base64"),"art":json.dumps(art).encode("base64"),"content_type":content_type})
	if isFolder:
		str='ActivateWindow(%d,"%s",return)'%(WID[content_type],link)
	else:
		str='RunPlugin("%s")'%link
	favs.appendChild(newnode)
	newnode.appendChild(res.createTextNode(str))
	dom.write(kodi_favxml,res)
	dialog = xbmcgui.Dialog()
	dialog.ok('UMP', '%s added to bookmarks'%name)
예제 #12
0
def get():
    if path.exists(setxml):
        res = dom.read(setxml)
        if not res:
            #minidom weirdness
            try:
                res.unlink()
            except:
                pass
            return "0"
        adv = getchild(res, res, "advancedsettings")
        nw = getchild(res, adv, "network")
        bm = getchild(res, nw, "buffermode")
        bm = bm.lastChild
        if bm is None:
            ret = "0"
        else:
            ret = bm.data
        res.unlink()
    else:
        ret = "0"
    return ret
예제 #13
0
def get():
	if path.exists(setxml):
		res=dom.read(setxml)
		if not res:
			#minidom weirdness
			try:
				res.unlink()
			except:
				pass
			return "0" 
		adv=getchild(res,res,"advancedsettings")
		nw=getchild(res,adv,"network")
		bm=getchild(res,nw,"buffermode")
		bm=bm.lastChild
		if bm is None:
			ret="0"
		else:
			ret=bm.data
		res.unlink()
	else:
		ret="0"
	return ret