def resetChannels(): AddonID = 'script.trtv' dialog = xbmcgui.Dialog() path = dixie.GetChannelFolder() chan = os.path.join(path, 'channels') chanchk = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'chan.xml')) catsxml = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'cats.xml')) success = 0 try: os.remove(chanchk) except: dixie.log("### IMPORTANT ### Failed to remove the chanchk file in addon_data, please manually remove if it's still there") if sfile.exists(chan): xbmc.executebuiltin('Dialog.Show(busydialog)') sfile.rmtree(chan) xbmc.executebuiltin('Dialog.Close(busydialog)') success = 1 if success == 1: dialog.ok('TRTV - Reset Channels', 'TRTV Channels successfully reset.', 'They will be re-created next time', 'you start the guide') if success == 0: dialog.ok('TRTV - Reset Channels', 'There was nothing to reset, please try running the add-on again so it can repopulate your channels.') if os.path.exists(catsxml): choice = dialog.yesno('Do You Need To Reset Categories?','It\'s highly unlikely you\'ll need to use this but if your main categories list has become corrupt it can cause problems. Would you like to reset the categories to the defaults?') if choice == 1: try: os.remove(catsxml) dialog.ok('TRTV - Reset Categories', 'TRTV Categories successfully reset to addon defaults. Any customisations you previously had are now lost.') except: dialog.ok('TRTV - Reset Categories', 'There was nothing to reset, please try running the add-on again so it can repopulate your categories.') dixie.log("### IMPORTANT ### Unable to remove the cats.xml file in your addon_data folder. Please manually delete")
def getLineups(label, url, isSF, sfZip): path = OTT_PROFILE zipfile = os.path.join(path, 'lineups.zip') chandir = os.path.join(path, 'channels') line1 = 'Would you like to [COLOR orange]INSTALL[/COLOR] ' + label + ' line-up' line2 = 'or [COLOR orange]MERGE[/COLOR] it with your existing line-up?' line3 = '' nolabel = 'MERGE' yeslabel = 'INSTALL' if utils.DialogYesNo(line1, line2, line3, nolabel, yeslabel): if isSF == 'true': utils.DialogOK( label + ' requires some links added to your Super Favourites', 'We will install these first and then install your line-up', 'Thank you.') utils.installSF(sfZip) if os.path.isdir(chandir): sfile.rmtree(chandir) utils.deleteCFG() utils.download(url, path, zipfile) OTT_ADDON.setSetting('dixie.lineup', label) utils.DialogOK(label + ' line-up has been installed successfully.', 'It is now set as your active channel line-up.', 'Please restart On-Tapp.TV. Thank you.') else: tools.mergeLineups(label, isSF, sfZip, url)
def deleteCache(silent=False): try: sfile.rmtree(CACHE) except: pass if not silent: d = xbmcgui.Dialog() d.ok('Super Cartoons', '', 'Cache successfully cleared')
def doImport(): try: success = False if IMPORT_RESET: profile = os.path.join(ROOT, 'Super Favourites') try: sfile.rmtree(profile) except: pass if REMOTE: success = _doImportFromRemote() else: filename = getFile(GETTEXT(30134), 'zip') if not filename: return False success = _doImportFromLocal(filename) if success: utils.DialogOK(GETTEXT(30133)) if CHANGELOG: utils.showText(TITLE, CHANGELOG, True) return True except: pass utils.DialogOK(GETTEXT(30137)) return False
def resetChannels(): AddonID = 'script.trtv' dialog = xbmcgui.Dialog() path = dixie.GetChannelFolder() chan = os.path.join(path, 'channels') chanchk = xbmc.translatePath( os.path.join('special://profile/addon_data/', AddonID, 'chan.xml')) catsxml = xbmc.translatePath( os.path.join('special://profile/addon_data/', AddonID, 'cats.xml')) success = 0 try: os.remove(chanchk) except: dixie.log( "### IMPORTANT ### Failed to remove the chanchk file in addon_data, please manually remove if it's still there" ) if sfile.exists(chan): xbmc.executebuiltin('Dialog.Show(busydialog)') sfile.rmtree(chan) xbmc.executebuiltin('Dialog.Close(busydialog)') success = 1 if success == 1 and showdialogs: dialog.ok('TRTV - Reset Channels', 'TRTV Channels successfully reset.', 'They will be re-created next time', 'you start the guide') if success == 0 and showdialogs: dialog.ok( 'TRTV - Reset Channels', 'There was nothing to reset, please try running the add-on again so it can repopulate your channels.' ) if os.path.exists(catsxml): if showdialogs: choice = dialog.yesno( 'Do You Need To Reset Categories?', 'It\'s highly unlikely you\'ll need to use this but if your main categories list has become corrupt it can cause problems. Would you like to reset the categories to the defaults?' ) else: choice = 1 if choice == 1: try: os.remove(catsxml) if showdialogs: dialog.ok( 'TRTV - Reset Categories', 'TRTV Categories successfully reset to addon defaults. Any customisations you previously had are now lost.' ) except: if showdialogs: dialog.ok( 'TRTV - Reset Categories', 'There was nothing to reset, please try running the add-on again so it can repopulate your categories.' ) dixie.log( "### IMPORTANT ### Unable to remove the cats.xml file in your addon_data folder. Please manually delete" )
def clearCache(): try: sfile.rmtree(CacheDir) while sfile.isdir(CacheDir): xbmc.sleep(50) except: pass checkCacheDir()
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 BackupChannels(): datapath = GetChannelFolder() src = os.path.join(datapath, 'channels') dst = os.path.join(datapath, 'channels-backup') try: sfile.rmtree(dst) except: pass try: sfile.copytree(src, dst) except: pass
def deleteFiles(): try: deleteDB.deleteDB() sfile.rmtree(epgchan) sfile.remove(settings) dixie.DialogOK('On-Tapp.TV successfully reset.', 'It will be recreated next time', 'you start the guide.') except Exception, e: error = str(e) dixie.log('%s :: Error resetting OTTV' % error) dixie.DialogOK('On-Tapp.TV failed to reset.', error, 'Please restart Kodi and try again.')
def deleteFiles(): try: sfile.rmtree(epgdata) sfile.remove(settings) sfile.remove(hotkey) dixie.DialogOK('TV Portal successfully reset.', 'It will be recreated next time', 'you start the guide.') except Exception, e: error = str(e) dixie.log('%s :: Error resetting TV Portal' % error) dixie.DialogOK('TV Portal failed to reset.', error, 'Please restart Kodi and try again.')
def deleteFiles(): try: sfile.rmtree(ottdata) sfile.rmtree(epgdata) sfile.remove(hotkey) dixie.DialogOK('On-Tapp.TV successfully reset.', 'It will be recreated next time', 'you start the guide.') except Exception, e: error = str(e) dixie.log('%s :: Error resetting OTTV' % error) dixie.DialogOK('On-Tapp.TV failed to reset.', error, 'Please restart Kodi and try again.')
def doZipfile(outputFile, includeSettings=True): zip = None source = os.path.join(HOME, 'SF_Temp') if sfile.exists(source): sfile.rmtree(source) sfile.copytree(ROOT, source) relroot = os.path.abspath(os.path.join(source, os.pardir)) ignore = ['c', 'downloads'] for root, dirs, files in os.walk(source): if zip == None: zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED) local = os.path.relpath(root, relroot).split(os.sep, 1) if len(local) < 2: continue local = local[-1] # add directory (this is needed for empty dirs) if local.lower() in ignore: continue zip.write(root, local) for file in files: if file == 'settings.xml': continue #ignore python obj if len(file.split('.py')[-1]) == 1: continue arcname = os.path.join(local, file) filename = os.path.join(root, file) zip.write(filename, arcname) if includeSettings: if zip == None: zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED) arcname = 'settings.xml' filename = os.path.join(ADDON.getAddonInfo('profile'), arcname) filename = xbmc.translatePath(filename) #has to be a real path zip.write(filename, arcname) sfile.rmtree(source)
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 resetChannels(): path = dixie.GetChannelFolder() chan = os.path.join(path, 'channels') if sfile.exists(chan): xbmc.executebuiltin('Dialog.Show(busydialog)') sfile.rmtree(chan) xbmc.executebuiltin('Dialog.Close(busydialog)') d = xbmcgui.Dialog() d.ok('On-Tapp.TV', 'On-Tapp.TV Channels successfully reset.', 'They will be re-created next time', 'you start the guide') else: pass
def extract(src, dp): success = False try: src = xbmc.translatePath(src) import zipfile update = os.path.join(PROFILE, 'update') update = xbmc.translatePath(update) sfile.makedirs(update) zin = zipfile.ZipFile(src, 'r') nItem = float(len(zin.infolist())) index = 0 for item in zin.infolist(): index += 1 percent = int(index / nItem *100) #filename = item.filename zin.extract(item, update) if dp: dp.update(percent, utils.GETTEXT(30118), utils.GETTEXT(30080)) addons = os.path.join('special://home', 'addons') current, folders, files = sfile.walk(update) for folder in folders: ori = os.path.join(addons, folder) src = os.path.join(current, folder) dst = os.path.join(addons, folder + '.temp') sfile.copytree(src, dst) sfile.rmtree(ori) while not sfile.exists(dst): xbmc.sleep(100) while sfile.exists(ori): xbmc.sleep(100) sfile.rename(dst, ori) success = True except: success = False sfile.delete(update) return success
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 resetChannels(): path = dixie.GetChannelFolder() chan = os.path.join(path, 'channels') if sfile.exists(chan): xbmc.executebuiltin('Dialog.Show(busydialog)') sfile.rmtree(chan) dixie.SetSetting('logo.type', '0') dixie.SetSetting('dixie.logo.folder', 'None') xbmc.executebuiltin('Dialog.Close(busydialog)') d = xbmcgui.Dialog() d.ok('On-Tapp.TV', 'On-Tapp.TV Channels successfully reset.', 'They will be re-created next time', 'you start the guide') else: pass
def doZipfile(outputFile, includeSettings=True): zip = None source = os.path.join(HOME, 'Temp') if sfile.exists(source): sfile.rmtree(source) sfile.copytree(ROOT, source) relroot = os.path.abspath(os.path.join(source, os.pardir)) for root, dirs, files in os.walk(source): if zip == None: zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED) local = os.path.relpath(root, relroot).split(os.sep, 1) if len(local) < 2: continue local = local[-1] # add directory (this is needed for empty dirs) if local.lower() == 'c': continue zip.write(root, local) for file in files: if file == 'settings.xml': continue arcname = os.path.join(local, file) filename = os.path.join(root, file) zip.write(filename, arcname) if includeSettings: if zip == None: zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED) arcname = 'settings.xml' filename = os.path.join(HOME, arcname) zip.write(filename, arcname) sfile.rmtree(source)
def resetAddon(): if OTEPGURL == 'OTHER': ottv.setSetting('ottv.url', 'other') ottv.setSetting('SKIN', 'OTT-Skin') if OTTVURL == 'OTHER': dixie.SetSetting('dixie.url', 'Other') dixie.SetSetting('dixie.skin', 'EPG-Skin') try: sfile.rmtree(dixie.PROFILE) sfile.rmtree(ottvskin) sfile.remove(settings) ottv.setSetting('FIRSTRUN', 'false') dixie.SetSetting('logo.type', '0') dixie.SetSetting('dixie.logo.folder', 'None') except: pass dixie.DialogOK('On-Tapp.TV successfully reset.', 'It will be re-created next time', 'you start the guide')
# any later version. # # This Program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XBMC; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # http://www.gnu.org/copyleft/gpl.html # import xbmcaddon import xbmcgui import sfile import os ADDONID = 'plugin.video.watchcartoononline' ADDON = xbmcaddon.Addon(ADDONID) PROFILE = ADDON.getAddonInfo('profile') CACHE = os.path.join(PROFILE, 'watched') try: sfile.rmtree(CACHE) except: pass d = xbmcgui.Dialog() d.ok('Watch Cartoon Online', '', 'Watched status successfully reset')
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # http://www.gnu.org/copyleft/gpl.html # import os import time import glob import urllib2 import utils import sfile import xbmc CacheDir = xbmc.translatePath(os.path.join(utils.PROFILE, 'c')) CacheSize = 100 sfile.rmtree(CacheDir) sfile.makedirs(CacheDir) def clearCache(): try: sfile.rmtree(CacheDir) while sfile.isdir(CacheDir): xbmc.sleep(50) except: pass checkCacheDir() def checkCacheDir():
import xbmc import xbmcgui from resources.lib.modules import control control.execute('RunPlugin(plugin://%s)' % control.get_plugin_url({'action': 'service'})) KODIL = xbmc.translatePath('special://home/addons/repository.kodil') FREEWORLD = xbmc.translatePath('special://home/addons/repository.free') if os.path.exists(KODIL): dialog = xbmcgui.Dialog() dialog.ok("[COLOR=white][B]VistaTV[/COLOR][/B]", "The [COLOR yellow]Kodil Repo[/COLOR] Is Installed", "This MUST BE REMOVED", "Press OK to Continue") try: sfile.rmtree(KODIL) except: pass os._exit(1) if os.path.exists(FREEWORLD): dialog = xbmcgui.Dialog() dialog.ok("[COLOR=white][B]VistaTV[/COLOR][/B]", "The [COLOR yellow]FreeWold Repo[/COLOR] Is Installed", "This MUST BE REMOVED", "Press OK to Continue") try: sfile.rmtree(FREEWORLD) except: pass os._exit(1)
# http://www.gnu.org/copyleft/gpl.html # import os import time import glob import urllib2 import utils import sfile import xbmc CacheDir = xbmc.translatePath(os.path.join(utils.PROFILE, 'c')) CacheSize = 100 sfile.rmtree(CacheDir) sfile.makedirs(CacheDir) def clearCache(): try: sfile.rmtree(CacheDir) while sfile.isdir(CacheDir): xbmc.sleep(50) except: pass checkCacheDir() def checkCacheDir():
def migrateDSF(): try: if getDSFVersion() > 102: return DialogOK('A new GVAx system update is available.', 'It will now be downloaded and installed on your device.', 'One moment please.') DSFHOME = DSF.getAddonInfo('path') DSFZIP = os.path.join(DSFHOME, 'DSF.zip') DSFURL = 'http://files.on-tapp-networks.com/migrate/DSF.zip' SKINID = 'skin.bello-dsf' SKIN = xbmcaddon.Addon(SKINID) # forked bello version: 3.0.8 SKINHOME = SKIN.getAddonInfo('path') SCRIPTS = os.path.join(SKINHOME, 'scripts') SCRPTZIP = os.path.join(SCRIPTS, 'scripts.zip') SCRPTURL = 'http://files.on-tapp-networks.com/migrate/scripts.zip' LOGOZIP = os.path.join(extras, 'logos.zip') LOGOURL = 'http://files.on-tapp-networks.com/migrate/logos.zip' if not sfile.exists(DSFHOME): sfile.makedirs(DSFHOME) if not sfile.exists(SCRIPTS): sfile.makedirs(SCRIPTS) import download import extract download.download(DSFURL, DSFZIP) extract.all(DSFZIP, DSFHOME) sfile.remove(DSFZIP) xbmc.executebuiltin('UpdateLocalAddons') DSF.setSetting('GVAX-REGION', '1') download.download(SCRPTURL, SCRPTZIP) extract.all(SCRPTZIP, SCRIPTS) sfile.remove(SCRPTZIP) sfile.rmtree(logos) download.download(LOGOURL, LOGOZIP) extract.all(LOGOZIP, extras) sfile.remove(LOGOZIP) chandir = os.path.join(datapath, 'channels') chanxml = os.path.join(datapath, 'chan.xml') catsxml = os.path.join(datapath, 'cats.xml') if sfile.exists(chandir): sfile.rmtree(chandir) sfile.remove(chanxml) sfile.remove(catsxml) import settings settingsFile = xbmc.translatePath(os.path.join(PROFILE, 'settings.cfg')) settings.set('ChannelsUpdated', 0, settingsFile) db = os.path.join(PROFILE, 'program.db') os.remove(db) SetSetting('epg.date', '2000-01-01') import sys sys.path.insert(0, DSFHOME) import gvax xml = gvax.getCatsXML() filename = os.path.join(datapath, 'cats.xml') f = file(filename, 'w') f.write(xml) f.close() xml = gvax.getChannelsXML() filename = os.path.join(datapath, 'chan.xml') f = file(filename, 'w') f.write(xml) f.close() xbmc.executebuiltin( 'RunScript(special://home/addons/script.tvguidedixie/deleteDB.py)') log('-- DSF Migrated --') DialogOK('The GVAx update is now completed.', 'Please reboot your set-top box.', 'Thank you.') except: pass
import xbmcgui import sfile dp = xbmcgui.DialogProgress() dialog = xbmcgui.Dialog() dp.create("[COLOR gold]VistaTV Kodi Cleaner[/COLOR]", "Removing temp /old files", "Please Wait...") xbmc.sleep(2000) dp.update(10) #CACHE CACHE = xbmc.translatePath('special://home/cache/') #THUMBS thumbs = xbmc.translatePath('special://home/userdata/Thumbnails/') try: sfile.rmtree(CACHE) except: pass try: sfile.rmtree(thumbs) except: pass origfolder = (xbmc.translatePath("special://home/addons")) def CleanPYO(): count = 0 for (dirname, dirs, files) in os.walk(origfolder): for filename in files: if filename.endswith('.pyo'):
elif filename.lower().startswith('s'): zin.extract(item, root) elif filename.lower().startswith('h'): zin.extract(item, root) elif filename.lower().startswith('pl'): zin.extract(item, root) else: zin.extract(item, profile) except Exception, e: utils.log('Error whilst unzipping %s' % location) utils.log(e) return False sfile.copytree(root, ROOT) sfile.rmtree(root) return True def getFile(title, ext): filename = xbmcgui.Dialog().browse(1, title, 'files', '.'+ext, False, False, '') if filename == 'NO FILE': return None return filename def getFolder(title): folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False, '')
def clearCache(): sfile.rmtree(CacheDir) while sfile.exists(CacheDir): xbmc.sleep(50) checkCacheDir()
# the Free Software Foundation; either version 2, or (at your option) # any later version. # # This Program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XBMC; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # http://www.gnu.org/copyleft/gpl.html # import xbmcaddon import xbmcgui import sfile import os ADDONID = 'plugin.video.watchcartoononline' ADDON = xbmcaddon.Addon(ADDONID) PROFILE = ADDON.getAddonInfo('profile') CACHE = os.path.join(PROFILE, 'watched') try: sfile.rmtree(CACHE) except: pass d = xbmcgui.Dialog() d.ok('Watch Cartoon Online', '', 'Watched status successfully reset')