def CheckVersion(): try: prev = ADDON.getSetting("VERSION") curr = VERSION if xbmcgui.Window(10000).getProperty("OTT_RUNNING") != "True": VerifyKeymaps() if prev == curr: return verifySuperSearch() src = os.path.join(ROOT, "cache") dst = os.path.join(ROOT, "C") sfile.rename(src, dst) ADDON.setSetting("VERSION", curr) if prev == "0.0.0" or prev == "1.0.0": sfile.makedirs(PROFILE) # call showChangeLog like this to workaround bug in openElec script = os.path.join(HOME, "showChangelog.py") cmd = "AlarmClock(%s,RunScript(%s),%d,True)" % ("changelog", script, 0) xbmc.executebuiltin(cmd) except: pass
def doDownload(file): utils.log('download url: %s' % file) dst = ADDON.getSetting('DOWNLOAD_FOLDER') import sfile sfile.makedirs(dst) if not sfile.isdir(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.isdir(dst): utils.DialogOK(GETTEXT(30256)) return 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')
def CheckVersion(): try: prev = ADDON.getSetting('VERSION') curr = VERSION if prev == curr: return verifySuperSearch() VerifySettinngs() VerifyZipFiles() src = os.path.join(ROOT, 'cache') dst = os.path.join(ROOT, 'C') sfile.rename(src, dst) ADDON.setSetting('VERSION', curr) if prev == '0.0.0' or prev == '1.0.0': sfile.makedirs(PROFILE) #call showChangeLog like this to workaround bug in openElec script = os.path.join(HOME, 'showChangelog.py') cmd = 'AlarmClock(%s,RunScript(%s),%d,True)' % ('changelog', script, 0) xbmc.executebuiltin(cmd) except: pass
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 install_file(filename): ottv = dixie.HOME src = os.path.join(ottv, 'resources', filename) if not os.path.exists(path): sfile.makedirs(path) sfile.copy(src, file)
def checkCacheDir(): try: if sfile.isdir(CacheDir): return except: pass sfile.makedirs(CacheDir)
def verifyPlugins(): folder = os.path.join(ROOT, 'Plugins') if sfile.exists(folder): return try: sfile.makedirs(folder) except: pass
def getDownloadLocation(): if getSetting('DOWNLOAD_LOC') == '1': loc = os.path.join(PROFILE, 'local') try: sfile.makedirs(loc) except: pass return loc return getExternalDrive()
def install_file(filename): vpn = utils.HOME src = os.path.join(vpn, 'resources', filename) if not os.path.exists(path): sfile.makedirs(path) sfile.copy(src, file)
def downloadDefaults(url): import download import extract url1 = url + "ott/skins.zip" url2 = url + "ottepg/skins.zip" url3 = url + "ottepg/logos.zip" url4 = url + "ottepg/channels.zip" path1 = xbmc.translatePath(PROFILE) # /addon_data/script.on-tapp.tv/ path2 = os.path.join(epgpath, "extras") # /addon_data/script.tvguidedixie/extras/ path3 = os.path.join(path2, "skins") path4 = os.path.join(path2, "logos") zip1 = os.path.join(path1, "skins.zip") zip2 = os.path.join(path2, "skins.zip") zip3 = os.path.join(path2, "logos.zip") zip4 = os.path.join(epgpath, "channels.zip") if not sfile.exists(epgpath): sfile.makedirs(epgpath) if not sfile.exists(path1): sfile.makedirs(path1) download.download(url1, zip1) extract.all(zip1, path1, dp="Installing OTT skins") sfile.remove(zip1) if not sfile.exists(path2): sfile.makedirs(path2) download.download(url2, zip2) extract.all(zip2, path2, dp="Installing EPG skins") sfile.remove(zip2) if not sfile.exists(path4): sfile.makedirs(path2) download.download(url3, zip3) extract.all(zip3, path2) sfile.remove(zip3) if not sfile.exists(epgpath): sfile.makedirs(epgpath) download.download(url4, zip4) extract.all(zip4, epgpath) sfile.remove(zip4) if OTTURL == "OTHER": Addon.setSetting("dixie.url", "Other") Addon.setSetting("dixie.skin", "EPG-Skin") setSetting("SKIN", "OTT-Skin") else: Addon.setSetting("dixie.url", "All Channels") Addon.setSetting("dixie.skin", "FXB v4.0") setSetting("SKIN", "FXB78") setSetting("FIRSTRUN", "true")
def GetFolder(title): default = ROOT sfile.makedirs(PROFILE) folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False, default) if folder == default: return None return folder
def downloadDefaults(url): import download import extract url1 = url + 'ott/skins.zip' url2 = url + 'ottepg/skins.zip' url3 = url + 'ottepg/logos.zip' url4 = url + 'ottepg/channels.zip' path1 = xbmc.translatePath(PROFILE) # /addon_data/script.on-tapp.tv/ path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/ path3 = os.path.join(path2, 'skins') path4 = os.path.join(path2, 'logos') zip1 = os.path.join(path1, 'skins.zip') zip2 = os.path.join(path2, 'skins.zip') zip3 = os.path.join(path2, 'logos.zip') zip4 = os.path.join(epgpath, 'channels.zip') if not sfile.exists(epgpath): sfile.makedirs(epgpath) if not sfile.exists(path1): sfile.makedirs(path1) download.download(url1, zip1) extract.all(zip1, path1, dp='Installing OTT skins') sfile.remove(zip1) if not sfile.exists(path2): sfile.makedirs(path2) download.download(url2, zip2) extract.all(zip2, path2, dp='Installing EPG skins') sfile.remove(zip2) if not sfile.exists(path4): sfile.makedirs(path2) download.download(url3, zip3) extract.all(zip3, path2) sfile.remove(zip3) if not sfile.exists(epgpath): sfile.makedirs(epgpath) download.download(url4, zip4) extract.all(zip4, epgpath) sfile.remove(zip4) if isDSF(): Addon.setSetting('dixie.skin', 'EPG-Skin') Addon.setSetting('playlist.url', '') setSetting('SKIN', 'OTT-Skin') else: Addon.setSetting('dixie.skin', 'FXB v4.0') setSetting('SKIN', 'FXB78') setSetting('FIRSTRUN', 'true')
def GetFolder(title): default = '' folder = xbmc.translatePath(PROFILE) if not sfile.isdir(folder): sfile.makedirs(folder) folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False, default) if folder == default: return None return xbmc.translatePath(folder)
def GetFolder(title, start=None): if start: default = start else: default = ROOT sfile.makedirs(PROFILE) folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False, default) if folder == default: if (not start): return None return folder
def verifySuperSearch(): old = os.path.join(ROOT, 'Search') dst = os.path.join(ROOT, 'S') sfile.rename(old, dst) try: sfile.makedirs(dst) except: pass src = os.path.join(HOME, 'resources', 'search', FILENAME) dst = os.path.join(dst, FILENAME) if not sfile.exists(dst): sfile.copy(src, dst) try: #patch any changes xml = sfile.read(dst) xml = xml.replace('is/?action=movies_search&', 'is/?action=movieSearch&') xml = xml.replace('is/?action=people_movies&', 'is/?action=moviePerson&') xml = xml.replace('is/?action=shows_search&', 'is/?action=tvSearch&') xml = xml.replace('is/?action=people_shows&', 'is/?action=tvPerson&') f = sfile.file(dst, 'w') f.write(xml) f.close() except: pass import favourite new = favourite.getFavourites(src, validate=False) #line1 = GETTEXT(30123) #line2 = GETTEXT(30124) for item in new: fave, index, nFaves = favourite.findFave(dst, item[2]) if index < 0: #line = line1 % item[0] #if DialogYesNo(line1=line, line2=line2): favourite.addFave(dst, item)
def verifySuperSearch(): src = os.path.join(ROOT, 'Search') dst = os.path.join(ROOT, 'S') sfile.rename(src, dst) dst = os.path.join(ROOT, 'S') src = os.path.join(HOME, 'resources', 'Search', FILENAME) try: sfile.makedirs(dst) except: pass dst = os.path.join(dst, FILENAME) if not sfile.exists(dst): sfile.copy(src, dst) try: #patch any changes xml = sfile.read(dst) xml = xml.replace('1channel/?mode=7000', '1channel/?mode=Search') xml = xml.replace('plugin.video.genesis/?action=actors_movies', 'plugin.video.genesis/?action=people_movies') xml = xml.replace('plugin.video.genesis/?action=actors_shows', 'plugin.video.genesis/?action=people_shows') f = sfile.file(dst, 'w') f.write(xml) f.close() except: pass import favourite new = favourite.getFavourites(src, validate=False) line1 = GETTEXT(30123) line2 = GETTEXT(30124) for item in new: fave, index, nFaves = favourite.findFave(dst, item[2]) if index < 0: line = line1 % item[0] if DialogYesNo(line1=line, line2=line2): favourite.addFave(dst, item)
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 add(keyword, image, fanart): if not exists(): try: sfile.makedirs(FILEPATH) except: pass if contains(keyword): return False newFave = [] newFave.append(keyword) newFave.append(image) newFave.append('%s?sf_options=fanart=%s_options_sf' % (keyword, urllib.quote_plus(fanart))) return favourite.addFave(FILENAME, newFave)
def verifySuperSearch(): src = os.path.join(ROOT, "Search") dst = os.path.join(ROOT, "S") sfile.rename(src, dst) dst = os.path.join(ROOT, "S") src = os.path.join(HOME, "resources", "Search", FILENAME) try: sfile.makedirs(dst) except: pass dst = os.path.join(dst, FILENAME) if not sfile.exists(dst): sfile.copy(src, dst) try: # patch any changes xml = sfile.read(dst) xml = xml.replace("1channel/?mode=7000", "1channel/?mode=Search") xml = xml.replace("plugin.video.genesis/?action=actors_movies", "plugin.video.genesis/?action=people_movies") xml = xml.replace("plugin.video.genesis/?action=actors_shows", "plugin.video.genesis/?action=people_shows") f = sfile.file(dst, "w") f.write(xml) f.close() except: pass import favourite new = favourite.getFavourites(src, validate=False) line1 = GETTEXT(30123) line2 = GETTEXT(30124) for item in new: fave, index, nFaves = favourite.findFave(dst, item[2]) if index < 0: line = line1 % item[0] if DialogYesNo(line1=line, line2=line2): favourite.addFave(dst, item)
def downloadDefaults(url): import download import extract url1 = url + 'ott/skins.zip' url2 = url + 'ottepg/skins.zip' url3 = url + 'ottepg/logos.zip' # url4 = url + 'ottepg/channels.zip' path1 = xbmc.translatePath(PROFILE) # /addon_data/script.on-tapp.tv/ path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/ path3 = os.path.join(path2, 'skins') path4 = os.path.join(path2, 'logos') zip1 = os.path.join(path1, 'skins.zip') zip2 = os.path.join(path2, 'skins.zip') zip3 = os.path.join(path2, 'logos.zip') # zip4 = os.path.join(epgpath, 'channels.zip') if not sfile.exists(epgpath): sfile.makedirs(epgpath) if not sfile.exists(path1): sfile.makedirs(path1) download.download(url1, zip1) extract.all(zip1, path1, dp='Installing OTT skins') sfile.remove(zip1) if not sfile.exists(path2): sfile.makedirs(path2) download.download(url2, zip2) extract.all(zip2, path2, dp='Installing EPG skins') sfile.remove(zip2) if not sfile.exists(path4): sfile.makedirs(path2) download.download(url3, zip3) extract.all(zip3, path2) sfile.remove(zip3) # if not sfile.exists(epgpath): # sfile.makedirs(epgpath) # download.download(url4, zip4) # extract.all(zip4, epgpath) # sfile.remove(zip4) Addon.setSetting('dixie.skin', 'EPG-Skin') Addon.setSetting('playlist.url', '') utils.setSetting('SKIN', 'OTT-Skin') if utils.DialogYesNo('Would you like to assign a button ', 'on your remote control or keybord', 'to activate the On-Tapp.TV Mini-Guide?'): xbmc.executebuiltin('RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py)') utils.setSetting('FIRSTRUN', 'true')
def downloadDefaults(url): DialogOK('Welcome to On-Tapp.TV 3.0', 'We will now install some needed files.', 'This may take a few minutes, so please be patient.') import download import extract url1 = url + 'ott/skins.zip' url2 = url + 'ottepg/skins.zip' url3 = url + 'ottepg/logos.zip' path1 = xbmc.translatePath(PROFILE) # /addon_data/script.on-tapp.tv/ path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/ path3 = os.path.join(path2, 'skins') path4 = os.path.join(path2, 'logos') zip1 = os.path.join(path1, 'skins.zip') zip2 = os.path.join(path2, 'skins.zip') zip3 = os.path.join(path2, 'logos.zip') zip4 = os.path.join(epgpath, 'channels.zip') if not sfile.exists(epgpath): sfile.makedirs(epgpath) if not sfile.exists(path1): sfile.makedirs(path1) download.download(url1, zip1) extract.all(zip1, path1, dp='Installing OTT skins') sfile.remove(zip1) if not sfile.exists(path2): sfile.makedirs(path2) download.download(url2, zip2) extract.all(zip2, path2, dp='Installing EPG skins') sfile.remove(zip2) if not sfile.exists(path4): sfile.makedirs(path2) download.download(url3, zip3) extract.all(zip3, path2) sfile.remove(zip3) Addon.setSetting('dixie.skin', 'FXB v4.0') setSetting('SKIN', 'FXB78') installSFPlugin() # if DialogYesNo('Would you like to assign a button ', 'on your remote control or keybord', 'to activate the On-Tapp.TV Mini-Guide?'): # xbmc.executebuiltin('RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py), True') setSetting('FIRSTRUN', 'true')
def CheckVersion(): prev = ADDON.getSetting('VERSION') curr = VERSION if prev == curr: return ADDON.setSetting('VERSION', curr) if prev == '0.0.0' or prev == '1.0.0': folder = xbmc.translatePath(PROFILE) if not sfile.isdir(folder): try: sfile.makedirs(folder) except: pass #call showChangeLog like this to workaround bug in openElec script = os.path.join(HOME, 'showChangelog.py') cmd = 'AlarmClock(%s,RunScript(%s),%d,True)' % ('changelog', script, 0) xbmc.executebuiltin(cmd)
def VerifyKeymapMenu(): context = ADDON.getSetting("CONTEXT") == "true" if not context: DeleteKeymap(KEYMAP_MENU) return True keymap = "special://profile/keymaps" dst = os.path.join(keymap, KEYMAP_MENU) if sfile.exists(dst): return False src = os.path.join(HOME, "resources", "keymaps", KEYMAP_MENU) sfile.makedirs(keymap) sfile.copy(src, dst) return True
def VerifyKeymapMenu(): context = ADDON.getSetting('CONTEXT') == 'true' if not context: DeleteKeymap(KEYMAP_MENU) return True keymap = 'special://profile/keymaps' dst = os.path.join(keymap, KEYMAP_MENU) if sfile.exists(dst): return False src = os.path.join(HOME, 'resources', 'keymaps', KEYMAP_MENU) sfile.makedirs(keymap) sfile.copy(src, dst) return True
def installSFPlugin(): sfavourites = 'plugin.program.super.favourites' sf_installed = xbmc.getCondVisibility('System.HasAddon(%s)' % sfavourites) == 1 if not sf_installed: return try: filename = 'OTTV Mini-Guide.py' sfaddon = xbmcaddon.Addon(id = sfavourites) path = sfaddon.getAddonInfo('profile') file = os.path.join(path, 'Plugins', filename) src = os.path.join(epghome, 'resources', filename) if not os.path.exists(path): sfile.makedirs(path) sfile.copy(src, file) except: pass
def CheckVersion(): prev = ADDON.getSetting("VERSION") curr = VERSION if prev == curr: return ADDON.setSetting("VERSION", curr) if prev == "0.0.0" or prev == "1.0.0": folder = xbmc.translatePath(PROFILE) try: if not sfile.isdir(folder): sfile.makedirs(folder) except: pass # call showChangeLog like this to workaround bug in openElec script = os.path.join(HOME, "showChangelog.py") cmd = "AlarmClock(%s,RunScript(%s),%d,True)" % ("changelog", script, 0) xbmc.executebuiltin(cmd)
def DownloadVideo(_url, title): resolved = resolve.ResolveURL(_url) title = utils.clean(title) if len(resolved) == 0: d = xbmcgui.Dialog() d.ok(TITLE + ' - ' + VERSION, 'Unable to download', title, 'Cannot find an online source') return auto = ADDON.getSetting('DOWNLOAD_AUTO') index = GetLinkIndex(resolved, not auto) if index < 0: return url = resolved[index][1] file = urllib.unquote_plus(url.rsplit('/')[-1]) file = utils.fileSystemSafe(file) folder = ADDON.getSetting('DOWNLOAD_FOLDER') if len(folder) == 0: folder = 'special://profile/addon_data/plugin.video.watchcartoononline/downloads' import sfile if not sfile.exists(folder): sfile.makedirs(folder) file = os.path.join(folder, file) try: import download download.download(url, file, title) except Exception, e: print '%s - %s Error during downloading of %s' % (TITLE, VERSION, title) print str(e)
def installSFPlugin(): sfavourites = 'plugin.program.super.favourites' sf_installed = xbmc.getCondVisibility('System.HasAddon(%s)' % sfavourites) == 1 if not sf_installed: return try: filename = 'OTTV Mini-Guide.py' sfaddon = xbmcaddon.Addon(id=sfavourites) path = sfaddon.getAddonInfo('profile') file = os.path.join(path, 'Plugins', filename) src = os.path.join(epghome, 'resources', filename) if not os.path.exists(path): sfile.makedirs(path) sfile.copy(src, file) except: pass
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
DIXIEURL = dixie.GetSetting('dixie.url').upper() GMTOFFSET = dixie.GetGMTOffset() datapath = dixie.PROFILE settingsFile = os.path.join(datapath, 'settings.cfg') USE_DB_FILE = True SETTINGS_TO_CHECK = ['dixie.url'] channelFolder = dixie.GetChannelFolder() channelPath = os.path.join(channelFolder, 'channels') dixie.log('Channel Folder Setting: %s' % channelPath) try: sfile.makedirs(channelPath) except: pass def GetDixieUrl(): return dixie.GetDixieUrl(DIXIEURL) def GetLogoType(): return dixie.GetSetting('logo.type') def GetLogoFolder(): CUSTOM = '1'
def checkUpdate(): if not FIRSTRUN: BASEURL = utils.getBaseURL(OTTURL) utils.DialogOK('Welcome to On-Tapp.TV 3.0', 'We will now do a back-up of any', 'existing files before installation.') utils.doBackup() if OTTURL == 'OTHER': Addon.setSetting('dixie.url', 'Other') Addon.setSetting('dixie.skin', 'EPG-Skin') utils.setSetting('SKIN', 'OTT-Skin') utils.downloadDefaults(BASEURL) else: response = getResponse() ottskin = response['OTTSkin'] epgskin = response['EPGSkin'] logocolour = response['LogoColour'] logowhite = response['LogoWhite'] ottupdate = response['OTTUpdate'] epgupdate = response['EPGUpdate'] curr = ottskin prev = utils.getSetting('OTTSKIN') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['OTT Skin Link'] path = xbmc.translatePath(PROFILE) path = os.path.join(path, 'skins') zipfile = os.path.join(path, 'skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadSkins(url, path, zipfile) utils.setSetting('OTTSKIN', curr) curr = epgskin prev = utils.getSetting('EPGSKIN') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['EPG Skin Link'] path = os.path.join(extras, 'skins') zipfile = os.path.join(path, 'skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadSkins(url, path, zipfile) utils.setSetting('EPGSKIN', curr) curr = logocolour prev = utils.getSetting('LOGOCOLOUR') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['Logo Colour'] path = os.path.join(logos, 'Colour Logo Pack') zipfile = os.path.join(path, 'logo-colour-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadLogos(url, path, zipfile) utils.setSetting('LOGOCOLOUR', curr) curr = logowhite prev = utils.getSetting('LOGOWHITE') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['Logo White'] path = os.path.join(logos, 'White Logo Pack') zipfile = os.path.join(path, 'logo-white-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadLogos(url, path, zipfile) utils.setSetting('LOGOWHITE', curr) curr = ottupdate prev = utils.getSetting('OTTUPDATE') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['OTT Update'] path = xbmc.translatePath(HOME) zipfile = os.path.join(path, 'python-update.zip') utils.doOTTUpdate(url, path, zipfile, ottupdate) utils.setSetting('OTTUPDATE', curr) curr = epgupdate prev = utils.getSetting('EPGUPDATE') if not prev == curr: url = utils.getBaseURL(OTTURL) + response['EPG Update'] path = xbmc.translatePath(epghome) zipfile = os.path.join(path, 'python-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.doEPGUpdate(url, path, zipfile, epgupdate) utils.setSetting('EPGUPDATE', curr)
def checkUpdate(): if not FIRSTRUN: BASEURL = utils.getBaseURL() utils.DialogOK( 'Bienvenido a GVAX', 'Ahora vamos a hacer una copia de seguridad de alguno de', 'los archivos existentes antes de la instalación.') doBackup() Addon.setSetting('dixie.skin', 'EPG-Skin') utils.setSetting('SKIN', 'OTT-Skin') downloadDefaults(BASEURL) return response = getResponse() ottskin = response['DSFOTTSkin'] epgskin = response['DSFEPGSkin'] logocolour = response['DSFLogos'] ottupdate = response['DSFOTTUpdate'] epgupdate = response['DSFEPGUpdate'] dsfupdate = response['DSFUpdate'] kodiskin = response['DSFKodiSkin'] curr = ottskin prev = utils.getSetting('DSFOTTSKIN') if not prev == curr: url = BASEURL + response['DSF OTT Skin'] path = xbmc.translatePath(PROFILE) path = os.path.join(path, 'skins') zipfile = os.path.join(path, 'dsf-skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadSkins(url, path, zipfile) utils.setSetting('DSFOTTSKIN', curr) curr = epgskin prev = utils.getSetting('DSFEPGSKIN') if not prev == curr: url = BASEURL + response['DSF EPG Skin'] path = os.path.join(extras, 'skins') zipfile = os.path.join(path, 'dsf-skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadSkins(url, path, zipfile) utils.setSetting('DSFEPGSKIN', curr) curr = logocolour prev = utils.getSetting('DSFLOGOS') if not prev == curr: url = BASEURL + response['DSF Logos'] path = os.path.join(logos, 'Colour Logo Pack') zipfile = os.path.join(path, 'dsf-logos-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadLogos(url, path, zipfile) utils.setSetting('DSFLOGOS', curr) curr = ottupdate prev = utils.getSetting('DSFOTTUPDATE') if not prev == curr: url = BASEURL + response['DSF OTT Update'] path = xbmc.translatePath(HOME) zipfile = os.path.join(path, 'dsf-ott-python.zip') doOTTUpdate(url, path, zipfile, ottupdate) utils.setSetting('DSFOTTUPDATE', curr) curr = epgupdate prev = utils.getSetting('DSFEPGUPDATE') if not prev == curr: url = BASEURL + response['DSF EPG Update'] path = xbmc.translatePath(epghome) zipfile = os.path.join(path, 'dsf-epg-python.zip') if not sfile.exists(path): sfile.makedirs(path) doEPGUpdate(url, path, zipfile, epgupdate) utils.setSetting('DSFEPGUPDATE', curr) curr = dsfupdate prev = utils.getSetting('DSFUPDATE') if not prev == curr: url = BASEURL + response['DSF Update'] path = xbmc.translatePath(home) zipfile = os.path.join(path, 'dsf-update.zip') if not sfile.exists(path): sfile.makedirs(path) doDSFUpdate(url, path, zipfile, dsfupdate) utils.setSetting('DSFUPDATE', curr) curr = kodiskin prev = utils.getSetting('DSFKODISKIN') if not prev == curr: url = BASEURL + response['DSF Kodi Skin'] path = xbmc.translatePath(skinhome) zipfile = os.path.join(path, 'dsf-kodi-skin.zip') if not sfile.exists(path): sfile.makedirs(path) doDSFUpdate(url, path, zipfile, kodiskin) utils.setSetting('DSFKODISKIN', curr) return
# import os import time import glob import urllib2 import loyal_book_utils as utils import sfile import xbmc CacheDir = xbmc.translatePath(os.path.join(utils.PROFILE, 'c')) CacheSize = 100 sfile.makedirs(CacheDir) def clearCache(): try: sfile.rmtree(CacheDir) while sfile.isdir(CacheDir): xbmc.sleep(50) except: pass checkCacheDir() def checkCacheDir(): try:
def SetDir(self, cache_dir): self.cache_dir = cache_dir if not sfile.exists(self.cache_dir): sfile.makedirs(self.cache_dir)
AddonID = 'script.tvportal' ADDON = xbmcaddon.Addon(id=AddonID) debug = ADDON.getSetting('DEBUG') showSFchannels = ADDON.getSetting('showSFchannels') SF_CHANNELS = ADDON.getSetting('SF_CHANNELS') adult = ADDON.getSetting('adult') add_sf_items = ADDON.getSetting('add_sf_items') USERDATA = xbmc.translatePath('special://profile/') ADDON_DATA = os.path.join(USERDATA,'addon_data') dbpath = os.path.join(ADDON_DATA,AddonID,'program.db') if SF_CHANNELS.startswith('special://'): SF_CHANNELS = xbmc.translatePath(SF_CHANNELS) try: sfile.makedirs(channelPath) except: pass ######################################################################################### # Find out whether the user has custom logos or built-in logos selected def GetLogoType(): return dixie.GetSetting('logo.type') ######################################################################################### # Set the global logo folder to use def GetLogoFolder(): CUSTOM = '1' logoType = GetLogoType() if logoType == CUSTOM: logoFolder = dixie.GetSetting('user.logo.folder') else:
debug = ADDON.getSetting('DEBUG') showSFchannels = ADDON.getSetting('showSFchannels') SF_CHANNELS = ADDON.getSetting('SF_CHANNELS') adult = ADDON.getSetting('adult') add_sf_items = ADDON.getSetting('add_sf_items') show_social = ADDON.getSetting('show_social') USERDATA = xbmc.translatePath('special://profile/') ADDON_DATA = os.path.join(USERDATA,'addon_data') dbpath = os.path.join(ADDON_DATA,AddonID,'program.db') datapath = dixie.PROFILE logoFolder = os.path.join(datapath,'extras','logos','Colour Logo Pack') if SF_CHANNELS.startswith('special://'): SF_CHANNELS = xbmc.translatePath(SF_CHANNELS) try: sfile.makedirs(channelPath) except: pass ######################################################################################### # Clean up the filename and remove chars that don't play nicely in python def CleanFilename(text): text = text.replace('*', '_star') text = text.replace('+', '_plus') text = text.replace(' ', '_') text = re.sub('[:\\/?\<>|"]', '', text) text = text.strip() try: text = text.encode('ascii', 'ignore') except: text = text.decode('utf-8').encode('ascii', 'ignore') return text.upper().replace('&','&') #########################################################################################
def checkCacheDir(): sfile.makedirs(CacheDir)
def doDownload(url, dest, title, referrer='', dp=None, silent=False): resp = getResponse(url, 0, referrer) if not resp: if not silent: utils.DialogOK(title, utils.GETTEXT(30081)) return try: content = int(resp.headers['Content-Length']) except: content = 0 try: resumable = 'bytes' in resp.headers['Accept-Ranges'].lower() except: resumable = False if resumable: utils.Log('Download is resumable') if content < 1: if not silent: utils.DialogOK(title, utils.GETTEXT(30081)) return import s3 dest = dest.replace(s3.DELIMETER, os.sep) folder = dest.rsplit(os.sep, 1)[0] sfile.makedirs(folder) size = CHUNK_SIZE * CHUNK_SIZE if size > content: size = content total = 0 notify = 0 errors = 0 count = 0 resume = 0 sleep = 0 f = sfile.file(dest, type='wb') sfile.file(dest+'.part', type='wb') chunk = None chunks = [] while True: abortRequested = xbmcgui.Window(10000).getProperty('LB_XBMC_ABORTED') == 'true' if abortRequested or (dp and dp.iscanceled()): f.close() utils.tidyUp(dest) return downloaded = total for c in chunks: downloaded += len(c) percent = min(100 * downloaded / content, 100) if percent >= notify: notify += 10 if dp: dp.update(int(percent), utils.GETTEXT(30079) % title, utils.GETTEXT(30080)) chunk = None error = False try: chunk = resp.read(size) if not chunk: if percent < 99: error = True else: while len(chunks) > 0: c = chunks.pop(0) f.write(c) del c f.close() utils.Log('%s download complete' % (dest)) sfile.remove(dest+'.part') return except Exception, e: utils.Log(str(e)) error = True sleep = 10 errno = 0 if hasattr(e, 'errno'): errno = e.errno if errno == 10035: # 'A non-blocking socket operation could not be completed immediately' pass if errno == 10054: #'An existing connection was forcibly closed by the remote host' errors = 10 #force resume sleep = 30 if errno == 11001: # 'getaddrinfo failed' errors = 10 #force resume sleep = 30 if chunk: errors = 0 chunks.append(chunk) if len(chunks) > CHUNK_CACHE: c = chunks.pop(0) f.write(c) total += len(c) del c if error: errors += 1 count += 1 utils.Log('%d Error(s) whilst downloading %s' % (count, dest)) xbmc.sleep(sleep*1000) if (resumable and errors > 0) or errors >= 10: if (not resumable and resume >= 10) or resume >= 100: #Give up! utils.Log('%s download canceled - too many error whilst downloading' % dest) if not silent: utils.DialogOK(dest, '' , utils.GETTEXT(30081)) return resume += 1 errors = 0 if resumable: chunks = [] #create new response utils.Log('Download resumed (%d) %s' % (resume, dest)) resp = getResponse(url, total, referrer) else: #use existing response pass
def checkUpdate(): if utils.isDSF(): import dsf try: dsf.checkUpdate() except: pass return if not FIRSTRUN: BASEURL = utils.getBaseURL() utils.doBackup() utils.downloadDefaults(BASEURL) return response = getResponse() ottskin = response['OTTSkin'] epgskin = response['EPGSkin'] logocolour = response['LogoColour'] logowhite = response['LogoWhite'] ottupdate = response['OTTUpdate'] epgupdate = response['EPGUpdate'] curr = ottskin prev = utils.getSetting('OTTSKIN') if not prev == curr: url = utils.getBaseURL() + response['OTT Skin Link'] path = xbmc.translatePath(PROFILE) path = os.path.join(path, 'skins') zipfile = os.path.join(path, 'skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadSkins(url, path, zipfile) utils.setSetting('OTTSKIN', curr) curr = epgskin prev = utils.getSetting('EPGSKIN') if not prev == curr: url = utils.getBaseURL() + response['EPG Skin Link'] path = os.path.join(extras, 'skins') zipfile = os.path.join(path, 'skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadSkins(url, path, zipfile) utils.setSetting('EPGSKIN', curr) curr = logocolour prev = utils.getSetting('LOGOCOLOUR') if not prev == curr: url = utils.getBaseURL() + response['Logo Colour'] path = os.path.join(logos, 'Colour Logo Pack') zipfile = os.path.join(path, 'logo-colour-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadLogos(url, path, zipfile) utils.setSetting('LOGOCOLOUR', curr) curr = logowhite prev = utils.getSetting('LOGOWHITE') if not prev == curr: url = utils.getBaseURL() + response['Logo White'] path = os.path.join(logos, 'White Logo Pack') zipfile = os.path.join(path, 'logo-white-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.downloadLogos(url, path, zipfile) utils.setSetting('LOGOWHITE', curr) curr = ottupdate prev = utils.getSetting('OTTUPDATE') if not prev == curr: url = utils.getBaseURL() + response['OTT Update'] path = xbmc.translatePath(HOME) zipfile = os.path.join(path, 'python-update.zip') utils.doOTTUpdate(url, path, zipfile, ottupdate) utils.setSetting('OTTUPDATE', curr) curr = epgupdate prev = utils.getSetting('EPGUPDATE') if not prev == curr: url = utils.getBaseURL() + response['EPG Update'] path = xbmc.translatePath(epghome) zipfile = os.path.join(path, 'python-update.zip') if not sfile.exists(path): sfile.makedirs(path) utils.doEPGUpdate(url, path, zipfile, epgupdate) utils.setSetting('EPGUPDATE', curr) return
# 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(): try:
def checkUpdate(): if not FIRSTRUN: utils.DialogOK('Bienvenido a GVAX', 'Ahora vamos a hacer una copia de seguridad de alguno de', 'los archivos existentes antes de la instalación.') doBackup() Addon.setSetting('dixie.skin', 'EPG-Skin') utils.setSetting('SKIN', 'OTT-Skin') downloadDefaults(BASEURL) return response = getResponse() ottskin = response['DSFOTTSkin'] epgskin = response['DSFEPGSkin'] logocolour = response['DSFLogos'] ottupdate = response['DSFOTTUpdate'] epgupdate = response['DSFEPGUpdate'] dsfupdate = response['DSFUpdate'] curr = ottskin prev = utils.getSetting('DSFOTTSKIN') if not prev == curr: url = BASEURL + response['DSF OTT Skin'] path = xbmc.translatePath(PROFILE) path = os.path.join(path, 'skins') zipfile = os.path.join(path, 'dsf-skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadSkins(url, path, zipfile) utils.setSetting('DSFOTTSKIN', curr) curr = epgskin prev = utils.getSetting('DSFEPGSKIN') if not prev == curr: url = BASEURL + response['DSF EPG Skin'] path = os.path.join(extras, 'skins') zipfile = os.path.join(path, 'dsf-skin-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadSkins(url, path, zipfile) utils.setSetting('DSFEPGSKIN', curr) curr = logocolour prev = utils.getSetting('DSFLOGOS') if not prev == curr: url = BASEURL + response['DSF Logos'] path = os.path.join(logos, 'Colour Logo Pack') zipfile = os.path.join(path, 'dsf-logos-update.zip') if not sfile.exists(path): sfile.makedirs(path) downloadLogos(url, path, zipfile) utils.setSetting('DSFLOGOS', curr) curr = ottupdate prev = utils.getSetting('DSFOTTUPDATE') if not prev == curr: url = BASEURL + response['DSF OTT Update'] path = xbmc.translatePath(HOME) zipfile = os.path.join(path, 'dsf-ott-python.zip') doOTTUpdate(url, path, zipfile, ottupdate) utils.setSetting('DSFOTTUPDATE', curr) curr = epgupdate prev = utils.getSetting('DSFEPGUPDATE') if not prev == curr: url = BASEURL + response['DSF EPG Update'] path = xbmc.translatePath(epghome) zipfile = os.path.join(path, 'dsf-epg-python.zip') if not sfile.exists(path): sfile.makedirs(path) doEPGUpdate(url, path, zipfile, epgupdate) utils.setSetting('DSFEPGUPDATE', curr) curr = dsfupdate prev = utils.getSetting('DSFUPDATE') if not prev == curr: url = BASEURL + response['DSF Update'] path = xbmc.translatePath(home) zipfile = os.path.join(path, 'dsf-update.zip') if not sfile.exists(path): sfile.makedirs(path) doDSFUpdate(url, path, zipfile, dsfupdate) utils.setSetting('DSFUPDATE', curr) return
def SetImageDir(self, image_dir): self.image_dir = image_dir if not sfile.exists(self.image_dir): sfile.makedirs(self.image_dir)