def copyFave(name, thumb, cmd): import os text = GETTEXT(30019) startFolder = '' if ADDON.getSetting('MENU_PREV_LOCN') == 'true': startFolder = xbmcgui.Window(10000).getProperty('SF_CAPTURE_FOLDER') if len(startFolder) == 0: startFolder = None folder = utils.GetFolder(text, startFolder) if not folder: return False xbmcgui.Window(10000).setProperty('SF_CAPTURE_FOLDER', folder) file = os.path.join(folder, utils.FILENAME) if ADDON.getSetting('MENU_EDITFAVE') == 'true': name = getText(GETTEXT(30021), name) if not name: return False fave = [name, thumb, cmd] return favourite.copyFave(file, fave)
def AddSFShortcut(): if not chooser.GetFave('OTT3'): return False path = xbmc.getInfoLabel('Skin.String(OTT3.Path)') label = xbmc.getInfoLabel('Skin.String(OTT3.Label)') icon = xbmc.getInfoLabel('Skin.String(OTT3.Icon)') folder = xbmc.getInfoLabel('Skin.String(OTT3.IsFolder)') == 'true' if len(path) == 0 or path == 'noop': return False fave = [label, icon, path] favourite.copyFave(SFFILE, fave) return True
def AddSFShortcut(file): if not chooser.GetFave('OTT'): return False path = xbmc.getInfoLabel('Skin.String(OTT.Path)') label = xbmc.getInfoLabel('Skin.String(OTT.Label)') icon = xbmc.getInfoLabel('Skin.String(OTT.Icon)') folder = xbmc.getInfoLabel('Skin.String(OTT.IsFolder)') == 'true' if len(path) == 0 or path == 'noop': return False fave = [removeNumeric(label), icon, path] favourite.copyFave(file, fave) return True
def sendkodiFave(superfolder, name, path, thumb): # cmd = getCmd(path='http://dl8.heyserver.in/serial/The.Big.Bang.Theory/S01/480p/The.Big.Bang.Theory.S01E13.480p.BluRay.x264.mkv',fanart='',desc='',window=100025,filename=name,isFolder=False,meta={'label': name},picture='fanart') #cmd = getCmd(path,fanart='',desc='',window=100025,filename=name,isFolder=False,meta={'label': name},picture='') cmd = getCmd(path,fanart=thumb,desc='',window=100025,filename=name,isFolder=False,meta={'label': name},picture='') #logging.warning("{0} {1} {2} {0}".format ('??'*15, 'cmd',cmd)) import os text = GETTEXT(30019) #folder = utils.GetSFFolder(text) #if not folder: # return False #file = os.path.join(folder, utils.FILENAME) file='/home/osmc/Super Favourites/'+superfolder+'/favourites.xml' if ADDON.getSetting('MENU_EDITFAVE') == 'true': name = getText(GETTEXT(30021), name) if not name: return False fave = [name, thumb, cmd] #logging.warning("{0} {1} {2} {0}".format ('??'*15, file,fave)) return favourite.copyFave(file, fave)
def pasteCopy(file, cmd, folder): copy, index, nFaves = favourite.findFave(file, cmd) if not copy: return False file = os.path.join(folder, FILENAME) return favourite.copyFave(file, copy)
def copyFave(file, cmd, move=False): copy, index, nFaves = favourite.findFave(file, cmd) if not copy: return False text = GETTEXT(30020) if move else GETTEXT(30019) folder = getFolder(text) if not folder: return False file = os.path.join(folder, FILENAME) return favourite.copyFave(file, copy)
def copyFave(name, thumb, cmd): import favourite text = GETTEXT(30019) folder = utils.GetFolder(text) if not folder: return False file = os.path.join(folder, utils.FILENAME) fave = [name, thumb, cmd] return favourite.copyFave(file, fave)
def copyFave(name, thumb, cmd): import os text = GETTEXT(30019) folder = utils.GetSFFolder(text) if not folder: return False file = os.path.join(folder, utils.FILENAME) if ADDON.getSetting('MENU_EDITFAVE') == 'true': name = getText(GETTEXT(30021), name) if not name: return False fave = [name, thumb, cmd] return favourite.copyFave(file, fave)
def copyFave(name, thumb, cmd): import favourite text = GETTEXT(30019) folder = utils.GetFolder(text) if not folder: return False file = os.path.join(folder, utils.FILENAME) if MENU_EDITFAVE: name = getText(GETTEXT(30021), name) if not name: return False fave = [name, thumb, cmd] return favourite.copyFave(file, fave)
def copyFave(name, thumb, cmd): import favourite import utils text = utils.GETTEXT(30019) folder = utils.GetFolder(text) if not folder: return False file = os.path.join(folder, utils.FILENAME) faves = favourite.getFavourites(file) #if it is already in there don't add again for fave in faves: if favourite.equals(fave[2], cmd): return False fave = [name, thumb, cmd] return favourite.copyFave(file, fave)
def ADDONINSTALL(name, url, cmd, filetype, repourl, fav_path): try: confirm = xbmcgui.Dialog().yesno('Please Confirm', ' Do you wish to install the chosen add-on and', ' its respective repository if needed?', ' ', 'Cancel', 'Install') #On cancel if confirm == 0: url = utils.getUrl() tags = utils.getTag() type = utils.getType() if type == "Official": mode = "official" ADDONLIST(url, mode,tags) elif type == "UnOfficial": mode = "unofficial" ADDONLIST(url, mode,tags) #On install elif confirm == 1: dp = xbmcgui.DialogProgress() dp.create('Download Progress:', 'Downloading repo...', '', 'Please Wait') if url != 'XBMC': checkRepo(url,dp) #Addon installation xml_url = utils.getUrl() link = OPEN_URL(xml_url) match = re.compile(XML_EXPRESSION_ITEM).findall(link) for id, title, icon, repolink, pluginlink, cmd, thumbnail, rating, type, description in match: if title == name: addon_url = pluginlink newfile = addon_url.rsplit('/',1)[1] newfile = newfile.rsplit('?',1)[0] try: version = newfile.rsplit('-',1)[1].rsplit('.',1)[0] except: #version is not available pass addonname = newfile.rsplit('-', 1)[0] addonname = str(addonname) addonname = addonname.replace('[', '') addonname = addonname.replace(']', '') addonname = addonname.replace('"', '') addonname = addonname.replace('[', '') addonname = addonname.replace("'", '') path = xbmc.translatePath(os.path.join('special://home/addons', 'packages')) current, dirs, files = os.walk(xbmc.translatePath('special://home/addons')).next() for dir in dirs: #zipfile already exist if dir == addonname: addon_path = os.path.join(xbmc.translatePath('special://home/addons'),addonname) addon_xml = os.path.join(addon_path,'addon.xml') tree = ET.parse(addon_xml) root = tree.getroot() existingVersion = root.attrib.get('version') if existingVersion == version: addon_cmd = '' xml_url = utils.getUrl() link = OPEN_URL(xml_url) match = re.compile(XML_EXPRESSION_ITEM).findall(link) for id, title, icon, repolink, pluginlink, cmd, thumbnail, rating, type, description in match: if title == name: addon_cmd = cmd icon_path = os.path.join(xbmc.translatePath('special://home/addons'),os.path.join(addonname,'icon.png')) fanart_path = os.path.join(xbmc.translatePath('special://home/addons'),os.path.join(addonname,'fanart.jpg')) if not os.path.exists(fanart_path): fanart_path = FANART copy = [] copy.append(name) copy.append(icon_path) copy.append(fanart_path) copy.append(addon_cmd) fav_file = os.path.join(fav_path, FILENAME) favourite.copyFave(fav_file, copy) #xbmcgui.Dialog().ok('Installed','Now you can use it directly from current folder') return 1 #zipfile not found lib = os.path.join(path, newfile) dp.update(0, 'Downloading plugin...') download(addon_url, lib, dp) if filetype == 'addon': addonfolder = xbmc.translatePath(os.path.join('special://', 'home/addons')) elif filetype == 'media': addonfolder = xbmc.translatePath(os.path.join('special://', 'home')) elif filetype == 'main': addonfolder = xbmc.translatePath(os.path.join('special://', 'home')) time.sleep(2) addonname = extract.all(lib, addonfolder, dp) addon_cmd = '' xml_url = utils.getUrl() link = OPEN_URL(xml_url) match = re.compile(XML_EXPRESSION_ITEM).findall(link) for id, title, icon, repolink, pluginlink, cmd, thumbnail, rating, type, description in match: if title == name: addon_cmd = cmd icon_path = os.path.join(addonfolder, os.path.join(addonname, 'icon.png')) fanart_path = os.path.join(xbmc.translatePath('special://home/addons'), os.path.join(addonname, 'fanart.jpg')) if not os.path.exists(fanart_path): fanart_path = FANART copy = [] copy.append(name) copy.append(icon_path) copy.append(fanart_path) copy.append(addon_cmd) fav_file = os.path.join(fav_path, FILENAME) favourite.copyFave(fav_file, copy) #Updated plugin addon_path = os.path.join(xbmc.translatePath('special://home/addons'),addonname) addon_xml = os.path.join(addon_path,'addon.xml') tree = ET.parse(addon_xml) root = tree.getroot() exVersion = root.attrib.get('version') digits = exVersion.rsplit('.') newVersion = '' #if int(digits[2]) != 0: # newVersion = exVersion.rsplit('.',1)[0] + '.0' #elif int(digits[1]) != 0: # newVersion = exVersion.split('.',1)[0] + '.0.0' #else: # newVersion = '0.0.0' newVersion = '0.0.0' root.set('version', newVersion) tree.write(addon_xml) #xbmc.executebuiltin( 'UpdateLocalAddons' ) #xbmc.executebuiltin( 'UpdateAddonRepos' ) #xbmcgui.Dialog().ok('Installed','Now you can use it directly from current folder') #updatePath = xbmc.translatePath('special://home/addons/plugin.program.tlbb.content/addonUpdate.py') #xbmc.executebuiltin( "RunScript(" + updatePath + ")") return 1 except Exception as e: xbmcgui.Dialog().ok('Error','Installation failed') path = utils.getCurrentPath() thepath = xbmc.translatePath(path) label = os.path.basename(thepath) link = "ReplaceWindow(10001,%s?label=%s&mode=%d&path=%s)" % (sys.argv[0] , label, 400, urllib.quote_plus(thepath)) xbmc.executebuiltin(link)