def VerifyKeymapHot(): if ADDON.getSetting('HOTKEY') == GETTEXT(30111): #i.e. programmable return False dest = os.path.join('special://profile/keymaps', KEYMAP_HOT) if sfile.exists(dest): return False key = ADDON.getSetting('HOTKEY') valid = [] for i in range(30028, 30040): valid.append(GETTEXT(i)) valid.append(GETTEXT(30058)) includeKey = key in valid if not includeKey: DeleteKeymap(KEYMAP_HOT) return True if isATV(): DialogOK(GETTEXT(30118), GETTEXT(30119)) return False return WriteKeymap(key.lower(), key.lower())
def get_logo(channel): logo = channel.logo logo_type = int(ADDON.getSetting('logos.source')) if logo and logo_type == LOGO_TYPE_DEFAULT: return logo logo_location = ADDON.getSetting('logos.folder') if not logo and logo_type == LOGO_TYPE_DEFAULT: logo = DEFAULT_LOGO_URL + 's' + channel.id + '_h3_aa.png' elif logo_type == LOGO_TYPE_CUSTOM and not logo.startswith(logo_location): logo = logo_location + channel.title + '.png' return logo
def get_logo(channel): logo = channel.logo logo_type = int(ADDON.getSetting('logos.source')) if logo and logo_type == LOGO_TYPE_DEFAULT: return logo logo_location = ADDON.getSetting('logos.folder') if not logo and logo_type == LOGO_TYPE_DEFAULT: logo = DEFAULT_LOGO_URL + 's' + channel.id + '_h3_aa.png' elif logo_type == LOGO_TYPE_CUSTOM and not logo.startswith(logo_location): logo = logo_location + channel.title + '.png' return logo
def run_service(): ok = True user = ADDON.getSetting('skyusername') passw = ADDON.getSetting('skypassword') if user == '' or passw == '': xbmc.log("[plugin.video.sportsaccess] No username or password configured!", xbmc.LOGWARNING) ok = False else: ok = verify_login(user, passw, False) if ok: xbmc.log("[plugin.video.sportsaccess] Service now being triggered...", xbmc.LOGNOTICE) Service() else: xbmc.log("[plugin.video.sportsaccess] Service cannot be triggered", xbmc.LOGWARNING)
def onCachesUpdated(self): if ADDON.getSetting('notifications.enabled') == 'true': n = notification.Notification(self.database, ADDON.getAddonInfo('path')) n.scheduleNotifications() self.database.close(None)
def get_setting(key, is_list=False): value = ADDON.getSetting(key) if value and is_list: value = json.loads(value) elif is_list: value = [] return value
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 get_setting(key, is_list=False): value = ADDON.getSetting(key) if value and is_list: value = json.loads(value) elif is_list: value = [] return value
def autocrop_image(image, border = 0): from PIL import Image, ImageOps size = image.size bb_image = image bbox = bb_image.getbbox() if (size[0] == bbox[2]) and (size[1] == bbox[3]): bb_image=bb_image.convert("RGB") bb_image = ImageOps.invert(bb_image) bbox = bb_image.getbbox() image = image.crop(bbox) (width, height) = image.size width += border * 2 height += border * 2 ratio = float(width)/height cropped_image = Image.new("RGBA", (width, height), (0,0,0,0)) cropped_image.paste(image, (border, border)) #TODO find epg height logo_height = 450 / int(ADDON.getSetting('channels.per.page')) logo_height = logo_height - 2 if ADDON.getSetting('program.channel.logo') == "false": cropped_image = cropped_image.resize((int(logo_height*ratio), logo_height),Image.ANTIALIAS) return cropped_image
def autocrop_image(image, border = 0): from PIL import Image, ImageOps size = image.size bb_image = image bbox = bb_image.getbbox() if (size[0] == bbox[2]) and (size[1] == bbox[3]): bb_image=bb_image.convert("RGB") bb_image = ImageOps.invert(bb_image) bbox = bb_image.getbbox() image = image.crop(bbox) (width, height) = image.size width += border * 2 height += border * 2 ratio = float(width)/height cropped_image = Image.new("RGBA", (width, height), (0,0,0,0)) cropped_image.paste(image, (border, border)) #TODO find epg height logo_height = 450 / int(ADDON.getSetting('channels.per.page')) logo_height = logo_height - 2 if ADDON.getSetting('program.channel.logo') == "false": cropped_image = cropped_image.resize((int(logo_height*ratio), logo_height),Image.ANTIALIAS) return cropped_image
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
xbmc.log("[plugin.video.sportsaccess] Service cannot be triggered", xbmc.LOGWARNING) if __name__ == '__main__': # After a restart the proc file should be wiped! path = xbmc.translatePath(ADDON.getAddonInfo('profile')) if not os.path.exists(path): os.mkdir(path) f = open(PROC_FILE, 'w') f.write('') f.close() try: ADDON = xbmcaddon.Addon('plugin.video.sportsaccess') if ADDON.getSetting('autostart') == "true": xbmc.executebuiltin("RunAddon(plugin.video.sportsaccess)") monitor = xbmc.Monitor() xbmc.log("[plugin.video.sportsaccess] Background service started...", xbmc.LOGNOTICE) run_service() interval = 1 # hard-coded to 1 hour if interval == 1: waitTime = 3600 # Default 1hr elif interval == 2: waitTime = 7200 # 2hrs elif interval == 6: waitTime = 21600 # 6hrs elif interval == 12: waitTime = 43200 # 12hrs
def get_kodi_version(): # retrieve current installed version jsonQuery = xbmc.executeJSONRPC( '{ "jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["version", "name"]}, "id": 1 }' ) jsonQuery = unicode(jsonQuery, 'utf-8', errors='ignore') jsonQuery = json.loads(jsonQuery) version = [] if jsonQuery.has_key('result') and jsonQuery['result'].has_key('version'): version = jsonQuery['result']['version'] return version['major'] if __name__ == '__main__': ok = True user = ADDON.getSetting('skyusername') passw = ADDON.getSetting('skypassword') if user == '' or passw == '': ok = login_popup() else: ok = verify_login(user, passw) if ok: # Apply Workaround for Kodi v17 on Android if xbmc.getCondVisibility('system.platform.android') and int( get_kodi_version()) == 17: ADDON.setSetting('background.stream', 'false') # After a restart the proc file should be wiped! f = open(PROC_FILE, 'w') f.write('')
def UpdateKeymaps(): if ADDON.getSetting('HOTKEY') != GETTEXT(30111): #i.e. not programmable DeleteKeymap(KEYMAP_HOT) DeleteKeymap(KEYMAP_MENU) VerifyKeymaps()
def GETTEXT(id): text = ADDON.getLocalizedString(id) name = ADDON.getLocalizedString(30121) if name == DISPLAY: return text text = text.replace(name, DISPLAY) return text ADDONID = 'script.opentvguide' ADDON = xbmcaddon.Addon(ADDONID) HOME = ADDON.getAddonInfo('path') ROOT = ADDON.getSetting('FOLDER') PROFILE = os.path.join(ROOT, 'Super Favourites') VERSION = ADDON.getAddonInfo('version') ICON = os.path.join(HOME, 'icon.png') FANART = os.path.join(HOME, 'fanart.jpg') SEARCH = os.path.join(HOME, 'resources', 'media', 'search.png') DISPLAY = ADDON.getSetting('DISPLAYNAME') TITLE = GETTEXT(30000) DEBUG = ADDON.getSetting('DEBUG') == 'true' KEYMAP_HOT = 'super_favourites_hot.xml' KEYMAP_MENU = 'super_favourites_menu.xml' MAJOR, MINOR = GetXBMCVersion() FRODO = (MAJOR == 12) and (MINOR < 9)