def extractAll(filename, dp, location): zin = zipfile.ZipFile(filename, 'r') source = ROOT relroot = os.path.abspath(os.path.join(source, os.pardir)) try: nItem = float(len(zin.infolist())) index = 0 for item in zin.infolist(): index += 1 percent = int(index / nItem *100) filename = item.filename if dp: dp.update(percent, GETTEXT(30140) % filename, location, GETTEXT(30141)) if filename == 'settings.xml': if utils.DialogYesNo(GETTEXT(30135), line2='', line3=GETTEXT(30136), noLabel=None, yesLabel=None): zin.extract(item, HOME) elif filename.lower().startswith('super favourites'): zin.extract(item, ROOT) elif filename.lower().startswith('search'): zin.extract(item, ROOT) else: zin.extract(item, PROFILE) except Exception, e: utils.log('Error whilst unzipping %s' % location) utils.log(e) return False
def doExport(): try: include = utils.DialogYesNo(GETTEXT(30129), line2='', line3=GETTEXT(30130), noLabel=None, yesLabel=None) folder = getFolder(GETTEXT(30131)) if not folder: return False filename = 'Super Favourites.zip' src = os.path.join(HOME, filename) dst = os.path.join(folder, filename) doZipfile(src, include) sfile.remove(dst) sfile.rename(src, dst) utils.DialogOK(GETTEXT(30132)) return True except Exception, e: utils.log('Error in doExport %s' % str(e))
def doDownload(file): utils.log('download url: %s' % file) dst = ADDON.getSetting('DOWNLOAD_FOLDER') import sfile sfile.makedirs(dst) if not sfile.exists(dst): utils.DialogOK(GETTEXT(30256), GETTEXT(30257)) utils.openSettings(ADDONID, 2.24) xbmc.sleep(500) while (xbmc.getCondVisibility('Window.IsActive(addonsettings)') == 1): xbmc.sleep(100) dst = ADDON.getSetting('DOWNLOAD_FOLDER') if not sfile.exists(dst): utils.DialogOK(GETTEXT(30256)) return import os dst = os.path.join(ADDON.getSetting('DOWNLOAD_FOLDER'), getDownloadTitle(file)) if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)): xbmc.executebuiltin('Action(Stop)') import download download.download(file, dst, utils.TITLE)
def deleteFile(path, name): if not utils.DialogYesNo(GETTEXT(30044) % name, GETTEXT(30045)): return import sfile sfile.delete(path) if sfile.exists(path): utils.DialogOK(GETTEXT(30046) % name)
def pasteFolder(dst, addonid): if len(dst) == 0: return False src = xbmcgui.Window(10000).getProperty('SF_FILE') cut = xbmcgui.Window(10000).getProperty('SF_TYPE').lower() == 'cutfolder' root = src.rsplit(os.sep, 1)[0] folderName = src.rsplit(os.sep, 1)[-1] same = (root == dst) link = True if dst == 'special://profile': #i.e. Kodi favourites if cut: cut = False line1 = GETTEXT(30187) % DISPLAYNAME line2 = GETTEXT(30188) % folderName line3 = GETTEXT(30189) link = utils.DialogYesNo(line1, line2, line3, noLabel=GETTEXT(30190), yesLabel=GETTEXT(30186)) if not link: return else: if cut: link = False else: line1 = GETTEXT(30183) % folderName link = True if same else utils.DialogYesNo(line1, GETTEXT(30184), noLabel=GETTEXT(30185), yesLabel=GETTEXT(30186)) if link: success = pasteFolderLink(src, dst, folderName, addonid) else: success = pasteFolderCopy(src, dst, folderName) if not success: line1 = GETTEXT(30191) % folderName utils.DialogOK(line1) return False if cut: import sfile sfile.rmtree(src) return success
def extractAll(filename, dp, location): global CHANGELOG CHANGELOG = None zin = zipfile.ZipFile(filename, 'r') relroot = os.path.abspath(os.path.join(ROOT, os.pardir)) root = os.path.join(HOME, 'SF_Temp') profile = os.path.join(root, 'Super Favourites') #copy existing settings to root dst = os.path.join(root, 'settings.xml') src = os.path.join(ROOT, 'settings.xml') sfile.copy(src, dst) if IMPORT_RESET: try: sfile.rmtree(os.path.join(ROOT, 'Super Favourites')) except: pass try: nItem = float(len(zin.infolist())) index = 0 for item in zin.infolist(): index += 1 percent = int(index / nItem * 100) filename = item.filename if dp: dp.update(percent, GETTEXT(30140) % filename, location, GETTEXT(30141)) if filename == 'settings.xml': if utils.DialogYesNo(GETTEXT(30135), line2='', line3=GETTEXT(30136), noLabel=None, yesLabel=None): zin.extract(item, root) elif filename == 'changelog.txt': try: zin.extract(item, root) filename = os.path.join(root, filename) CHANGELOG = sfile.read(filename) utils.DeleteFile(filename) except Exception, e: utils.log('Changelog error in extractAll') utils.log(e) elif filename.lower().startswith('super favourites'): zin.extract(item, root) elif filename.lower().startswith('s'): zin.extract(item, root)
def main(): if xbmcgui.Window(10000).getProperty('SF_MENU_VISIBLE') == 'true': return if ADDON.getSetting('MENU_MSG') == 'true': ADDON.setSetting('MENU_MSG', 'false') if utils.DialogYesNo(GETTEXT(35015), GETTEXT(35016), GETTEXT(35017)): utils.openSettings(ADDONID, 2.1) return doMenu()
def removeFolder(path): label = path.rsplit(os.sep, 1)[-1] if not utils.DialogYesNo( GETTEXT(30016) % label, GETTEXT(30017), GETTEXT(30018)): return False try: shutil.rmtree(path) except: pass return True
def menu(mode): if xbmcgui.Window(10000).getProperty('SF_MENU_VISIBLE') == 'true': return if ADDON.getSetting('MENU_MSG') == 'true': ADDON.setSetting('MENU_MSG', 'false') if utils.DialogYesNo(GETTEXT(35015), GETTEXT(35016), GETTEXT(35017)): utils.openSettings(ADDONID, 2.6) return #xbmc.executebuiltin('Dialog.Close(all, true)') doMenu(mode)
def getLogos(label, url): path = os.path.join(EXTRAS, 'logos') zipfile = os.path.join(path, 'logos.zip') if utils.DialogYesNo( 'Would you like to install ' + label, 'and make it your active logo-pack?', 'It will be downloaded and installed into your system.'): download(path, zipfile) utils.DialogOK(label + ' logo-pack has been installed successfully.', 'It is now set as your active logo-pack.', 'Please restart On-Tapp.TV. Thank you.') OTT_ADDON.setSetting('dixie.logo.folder', label)
def AddShortcut(): ADDMORE = int(utils.getSetting('ADDMORE')) if ADDMORE == 0: return AddAddonShortcut() if not SF_INSTALLED: return AddAddonShortcut() if ADDMORE == 2 and utils.DialogYesNo(GETTEXT(30313), GETTEXT(30314), '', GETTEXT(30315), GETTEXT(30316)): return AddAddonShortcut() return AddSFShortcut()
def doExport(): try: include = utils.DialogYesNo(GETTEXT(30129), line2='', line3=GETTEXT(30130), noLabel=None, yesLabel=None) folder = getFolder(GETTEXT(30131)) if not folder: return False filename = os.path.join(folder, 'Super Favourites.zip') doZipfile(filename, include) utils.DialogOK(GETTEXT(30132)) return True except Exception, e: utils.log(e)
def removeChannel(id): channel = getChannelFromFile(id) if not channel: return False if channel.userDef != 1 and channel.isClone != 1: return False if not utils.DialogYesNo( 'Remove %s' % channel.title, noLabel='Cancel', yesLabel='Confirm'): return False path = os.path.join(OTT_CHANNELS, id) utils.deleteFile(path) return True
def extractAll(filename, dp, location): global CHANGELOG CHANGELOG = None zin = zipfile.ZipFile(filename, 'r') source = ROOT relroot = os.path.abspath(os.path.join(source, os.pardir)) try: nItem = float(len(zin.infolist())) index = 0 for item in zin.infolist(): index += 1 percent = int(index / nItem * 100) filename = item.filename if dp: dp.update(percent, GETTEXT(30140) % filename, location, GETTEXT(30141)) if filename == 'settings.xml': if utils.DialogYesNo(GETTEXT(30135), line2='', line3=GETTEXT(30136), noLabel=None, yesLabel=None): zin.extract(item, HOME) elif filename == 'changelog.txt': try: zin.extract(item, ROOT) filename = os.path.join(ROOT, filename) file = open(filename, 'r') CHANGELOG = file.read() file.close() utils.DeleteFile(filename) except Exception, e: print str(e) pass elif filename.lower().startswith('super favourites'): zin.extract(item, ROOT) elif filename.lower().startswith('search'): zin.extract(item, ROOT)
def getSkinImage(): image = '' skin = xbmc.getSkinDir().lower() icon = os.path.join(HOME, 'resources', skin, 'icons') items = ['Super Favourite'] if os.path.exists(icon): f = open(icon, 'r') for line in f: items.append(line.strip()) f.close() if (len(items) > 1) and utils.DialogYesNo(GETTEXT(30046)): import imagebrowser return imagebrowser.getImage(ADDONID, items) return getImage()
def onAction(self, action): #see here https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h for the full list actionId = action.getId() buttonId = action.getButtonCode() if actionId != 107: utils.Log('onAction actionID %d' % actionId) utils.Log('onAction buttonID %d' % buttonId) if actionId in [ACTION_CONTEXT, ACTION_RCLICK]: return self.onContextMenu() if actionId in [ACTION_PARENT_DIR, ACTION_BACK] or buttonId in [ESC]: if not confirmExit or utils.DialogYesNo( 'Are you sure you wish to quit Community Portal?'): return self.onBack() return # return self.onBack() try: id = self.getFocus().getId() except: id = 0 select = (actionId == ACTION_SELECT) or (actionId == ACTION_LCLICK) if select and id == MAINLIST: liz = self.getSelectedItem() param = liz.getProperty('Param') image = liz.getProperty('Image') mode = int(liz.getProperty('Mode')) isFolder = liz.getProperty('IsFolder') == 'true' isPlayable = liz.getProperty('IsPlayable') == 'true' if mode == LISTBACK: return self.onBack() if param: self.stopTimer() self.onParams(param, isFolder) self.resetTimer() if select and id == CATEGORIES: categoriesList = categories.getSetting('categories').split('|') if categoriesList[0] == '': categoriesList = [] functionality.ShowCategories(categoriesList) if select and id == SETTINGS: addonID = 'script.tvportal.epg' functionality.ShowSettings(addonID) if select and id == TOOLS: functionality.OpenTools() if select and id == TVGUIDE: xbmc.executebuiltin('RunScript(script.tvportal.epg)') if select and id == MOVIES: if utils.getSetting('KodiLib') == 'true': xbmc.executebuiltin( 'ActivateWindow(10501,plugin://plugin.video.genesis/?action=movieNavigator,return)' ) else: xbmc.executebuiltin( 'ActivateWindow(10025,videodb://1/2,return)') if select and id == TVSHOWS: if utils.getSetting('KodiLib') == 'true': xbmc.executebuiltin( 'ActivateWindow(10501,plugin://plugin.video.genesis/?action=tvNavigator,return)' ) else: xbmc.executebuiltin( 'ActivateWindow(10025,videodb://2/2,return)') if select and id == NETFLIX: xbmc.executebuiltin( 'StartAndroidActivity("com.netflix.mediaclient"),return') if select and id == MOVIEANDTV: xbmc.executebuiltin('XBMC.RunAddon(plugin.video.genesis)') if select and id == WORLDTV: xbmc.executebuiltin('XBMC.RunAddon(plugin.video.alluc.api)') if select and id == ANDROID: xbmc.executebuiltin( 'ActivateWindow(10025,androidapp://sources/apps,return)') if select and id == ADULT: xbmc.executebuiltin( 'ActivateWindow(10501,plugin://plugin.program.super.favourites/?label=Adult&mode=400&path=special://userdata/addon_data/plugin.program.super.favourites/Super Favourites/Adult/,return)' ) if select and id == VIDEOWINDOW: xbmc.executebuiltin('Action(fullscreen)')
def onParams(application, _params): global APPLICATION APPLICATION = application params = get_params(_params) mode = None try: mode = int(urllib.unquote_plus(params['mode'])) except: pass try: url = urllib.unquote_plus(params['url']) except: url = None if mode == _SCRIPT: cmd = 'RunScript(%s)' % url xbmc.executebuiltin(cmd) elif mode == _ADDON: xbmc.executebuiltin('ActivateWindow(%d,"plugin://%s/",return)' % (WINDOWID, url)) elif mode == _SUPERFAVE: xbmc.executebuiltin(url) elif mode == _REMOVESUPERFAVE: if RemoveSFShortcut(url): APPLICATION.containerRefresh() elif mode == _MOVIES: if utils.getSetting('KodiLib') == 'true': sfmovies = xbmc.translatePath( 'special://profile/addon_data/plugin.program.super.favourites/Super Favourites/Movies' ) if not os.path.exists(sfmovies): try: os.makedirs(sfmovies) except: pass xbmc.executebuiltin( 'ActivateWindow(10001,plugin://plugin.program.super.favourites/?label=Movies&mode=400&path=special://profile/addon_data/plugin.program.super.favourites/Super Favourites/Movies,return)' ) else: xbmc.executebuiltin('ActivateWindow(10025,videodb://1/2,return)') elif mode == _TVSHOWS: if utils.getSetting('KodiLib') == 'true': sftvshows = xbmc.translatePath( 'special://profile/addon_data/plugin.program.super.favourites/Super Favourites/TV Shows' ) if not os.path.exists(sftvshows): try: os.makedirs(sftvshows) except: pass xbmc.executebuiltin( 'ActivateWindow(10001,plugin://plugin.program.super.favourites/?label=TV Shows&mode=400&path=special://profile/addon_data/plugin.program.super.favourites/Super Favourites/TV Shows,return)' ) else: xbmc.executebuiltin('ActivateWindow(10025,videodb://2/2,return)') elif mode == _CATEGORIES: ShowCategories(categoriesList) elif mode == _SETTINGS: ShowSettings() elif mode == _INI: cmd = 'XBMC.RunScript(special://home/addons/script.tvportal.epg/getIni.py)' xbmc.executebuiltin(cmd) elif mode == _ADDONS_POPULAR: xbmc.executebuiltin( 'ActivateWindow(10001,plugin://plugin.program.totalinstaller/?mode=addonmenu,return)' ) #put while folder is the CP addons folder sleep 500 path = str(xbmc.getInfoLabel('ListItem.FolderPath')) while 'addon' in path: xbmc.sleep(500) path = str(xbmc.getInfoLabel('ListItem.FolderPath')) xbmc.executebuiltin( 'RunScript(special://home/addons/script.community.portal/?mode=_ADDONS_POPULAR)' ) # % (WINDOWID, url, 'addonsmenu')) elif mode == _CHANNELS: xbmc.executebuiltin('ActivateWindow(%d,"plugin://%s/?mode=%d")' % (WINDOWID, TOOLS, 1900)) elif mode == _SKINS: xbmc.executebuiltin('ActivateWindow(%d,"plugin://%s/?mode=%d")' % (WINDOWID, TOOLS, 2000)) elif mode == _LOGOS: xbmc.executebuiltin('ActivateWindow(%d,"plugin://%s/?mode=%d")' % (WINDOWID, TOOLS, 2100)) elif mode == _TOOLS: ShowTools() elif mode == _YOUTUBE: PlayYT(url) elif mode == _VPNICITY: SelectVPNicity(url) elif mode == _CATCHUP: ShowCatchup() elif mode == _COMMUNITY_BUILDS: communitybuildpath = xbmc.translatePath( 'special://home/addons/script.community.builds') if os.path.exists(communitybuildpath): xbmc.executebuiltin( 'RunScript(special://home/addons/script.community.builds/default.py)' ) else: choice = utils.DialogYesNo( 'Add-on Required', 'You need the Community Builds module installed to access this section. Would you like to install now?' ) if choice == 1: print "download function required" try: download.download( 'http://github.com/noobsandnerds/zips/script.community.builds/script.community.builds.zip', os.path.join(PACKAGES, 'update.zip')) extract.all(os.path.join(PACKAGES, 'update.zip'), ADDONS) except: print "### Failed to download and extract Community Builds add-on" # ShowAddonsMenu() elif mode == _ADDONS: addonportalpath = xbmc.translatePath( 'special://home/addons/script.addon.portal') if os.path.exists(addonportalpath): xbmc.executebuiltin( 'RunScript(special://home/addons/script.addon.portal/default.py)' ) else: choice = utils.DialogYesNo( 'Add-on Required', 'You need the Add-on Portal module installed to access this section. Would you like to install now?' ) if choice == 1: print "download function required" try: download.download( 'http://github.com/noobsandnerds/zips/script.addon.portal/script.addon.portal.zip', os.path.join(PACKAGES, 'update.zip')) extract.all(os.path.join(PACKAGES, 'update.zip'), ADDONS) except: print "### Failed to download and extract Addon Portal" elif mode == _SUPERSEARCH: SelectSuperSearch(url) elif mode == _SHOWSHORTCUTS: ShowShortcuts() elif mode == _ADDSHORTCUT: if AddShortcut(): APPLICATION.containerRefresh() elif mode == _REMOVESHORTCUT: if RemoveShortcut(url): APPLICATION.containerRefresh() # elif mode == _REMOVEADDONSHORTCUT: # RemoveAddonShortcut() else: Main()
except: pass if choice == _STD_MENU: doStandard(useScript=True) if choice == _PLAYLIST: activateWindow('videoplaylist') if choice == _DOWNLOAD: utils.log('download url: %s' % file) dst = os.path.join(ADDON.getSetting('DOWNLOAD_FOLDER'), getDownloadTitle(file)) if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)): xbmc.Player().stop() import download download.download(file, dst, 'Super Favourites') if choice == _SF_SETTINGS: utils.ADDON.openSettings() if choice == _SETTINGS: xbmcaddon.Addon(localAddon).openSettings() if choice == _ADDTOFAVES: