def regPseudoTV(): while not MONITOR.abortRequested(): WAIT_TIME = 300 if xbmc.getCondVisibility( 'System.HasAddon(plugin.video.pseudotv.live)'): try: asset = json.loads(xbmcgui.Window(10000).getProperty(PROP_KEY)) except: asset = {} asset['vod'] = [{ 'type': 'vod', 'name': 'HDHomerun %s' % (LANGUAGE(30111)), 'description': '', 'icon': LOGO, 'path': 'plugin://%s/recordings/All' % (ADDON_ID), 'id': ADDON_ID }] if xbmc.getCondVisibility('System.HasAddon(service.iptv.manager)'): if REAL_SETTINGS.getSettingBool('iptv.enabled'): WAIT_TIME = 900 try: # Manager Info IPTV_MANAGER = xbmcaddon.Addon( id='service.iptv.manager') IPTV_PATH = IPTV_MANAGER.getAddonInfo('profile') IPTV_M3U = os.path.join(IPTV_PATH, 'playlist.m3u8') IPTV_XMLTV = os.path.join(IPTV_PATH, 'epg.xml') asset['iptv'] = { 'type': 'iptv', 'name': ADDON_NAME, 'icon': ICON.replace( ADDON_PATH, 'special://home/addons/%s/' % (ADDON_ID)).replace('\\', '/'), 'm3u': { 'path': IPTV_M3U, 'slug': '@%s' % (slugify(ADDON_NAME)) }, 'xmltv': { 'path': IPTV_XMLTV }, 'id': ADDON_ID } except Exception as e: asset['iptv'] = {} xbmc.log( '%s-%s-regPseudoTV failed! %s' % (ADDON_ID, ADDON_VERSION, e), xbmc.LOGERROR) else: asset['iptv'] = {} xbmcgui.Window(10000).setProperty(PROP_KEY, json.dumps(asset)) else: xbmcgui.Window(10000).clearProperty(PROP_KEY) if MONITOR.waitForAbort(WAIT_TIME): break
def _onTimeout(self): self._endTime = 0 xbmcgui.Window(self._winID).setProperty(self._property, self._value) if self._addonID: xbmcgui.Window(10000).setProperty('{0}.{1}'.format(self._addonID, self._property), self._value) if self._closeWin: self._closeWin.doClose() if self._callback: self._callback()
def onClose(self): log('onClose') setRepeat(REAL_SETTINGS.getSetting('RepeatState').lower()) xbmcgui.Window(10000).clearProperty('script.trakt.paused') xbmcgui.Window(10000).clearProperty('%s.Running'%(ADDON_ID)) setVolume(int(xbmcgui.Window(10000).getProperty('%s.RESTORE'%ADDON_ID))) self.myPlayer.stop() self.playList.clear() self.close()
def init(self, val): if val is False: return elif val is None: val = self._initValue xbmcgui.Window(self._winID).setProperty(self._property, val) if self._addonID: xbmcgui.Window(10000).setProperty('{0}.{1}'.format(self._addonID, self._property), val)
def _get_vars(self): PLog('_get_vars') # get the slideshow window id self.winid = xbmcgui.Window(xbmcgui.getCurrentWindowDialogId()) PLog('self.winid: ' + str(self.winid)) self.pos = 0 self.stop = False
def sign_in_to_plex(context, refresh=True): status = False try: with PlexSignin(i18n('myPlex Login'), window=xbmcgui.Window(10000)) as dialog: dialog.set_context(context) dialog.start() status = dialog.signed_in() except AlreadyActiveException: pass except AttributeError: response = context.plex_network.get_signin_pin() message = \ i18n('From your computer, go to [B]%s[/B] and enter the following code: [B]%s[/B]') % \ ('https://www.plex.tv/link/', ' '.join(response.get('code', []))) DIALOG.ok(i18n('myPlex Login'), message) xbmc.sleep(500) result = context.plex_network.check_signin_status( response.get('id', '')) if result: status = True LOG.debug('Sign in successful ...') else: LOG.debug('Sign in failed ...') if refresh: xbmc.executebuiltin('Container.Refresh') return status
def __init__(self): params = self.get_params() if params: color_picker = cp.ColorPicker( "script-skin_helper_service-ColorPicker.xml", ADDON_PATH, "Default", "1080i") color_picker.skinstring = params.get("SKINSTRING", "") color_picker.win_property = params.get("WINPROPERTY", "") color_picker.active_palette = params.get("PALETTE", "") color_picker.header_label = params.get("HEADER", "") propname = params.get("SHORTCUTPROPERTY", "") color_picker.shortcut_property = propname color_picker.doModal() #special action when we want to set our chosen color into a skinshortcuts property if propname and not isinstance(color_picker.result, int): self.wait_for_skinshortcuts_window() xbmc.sleep(400) current_window = xbmcgui.Window( xbmcgui.getCurrentWindowDialogId()) current_window.setProperty("customProperty", propname) current_window.setProperty("customValue", color_picker.result[0]) xbmc.executebuiltin("SendClick(404)") xbmc.sleep(250) current_window.setProperty("customProperty", "%s.name" % propname) current_window.setProperty("customValue", color_picker.result[1]) xbmc.executebuiltin("SendClick(404)") del color_picker
def run(): settings = AddonSettings() sleep_time = 10 LOG.debug('Service initialization...') window = xbmcgui.Window(10000) player = CallbackPlayer(window=window, settings=settings) monitor = Monitor(settings) companion_thread = None while not monitor.abortRequested(): if not companion_thread and settings.use_companion(): _fresh_settings = AddonSettings() companion_thread = companion.CompanionReceiverThread(get_client(_fresh_settings), _fresh_settings) del _fresh_settings elif companion_thread and not settings.use_companion(): companion.shutdown(companion_thread) companion_thread = None if monitor.waitForAbort(sleep_time): break companion.shutdown(companion_thread) player.cleanup_threads(only_ended=False) # clean up any/all playback monitoring threads
def __init__(self, w=OVERLAY_WIDTH, h=OVERLAY_HEIGHT, *args, **kwargs): self.window = xbmcgui.Window(WINDOW_FULLSCREEN_VIDEO) viewport_w, viewport_h = self._get_skin_resolution() # Adjust size based on viewport, we are using 1080p coordinates w = int(w * viewport_w / VIEWPORT_WIDTH) h = int(h * viewport_h / VIEWPORT_HEIGHT) x = (viewport_w - w) / 2 y = (viewport_h - h) / 2 + int( ADDON.getSetting(id="overlay_status_offset")) self._shown = False self._text = "" self._label = xbmcgui.ControlLabel(x, y, w, h, self._text, alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y, *args, **kwargs) self._shadow = xbmcgui.ControlLabel(x + 1, y + 1, w, h, self._text, textColor='0xD0000000', alignment=XBFONT_CENTER_X | XBFONT_CENTER_Y, *args, **kwargs) self._background = xbmcgui.ControlImage( x, y, w, h, os.path.join(ADDON_PATH, "resources", "img", "black.png").encode('utf-8')) self._background.setColorDiffuse("0xD0000000")
def __init__(self, *args, **kwargs): # activate the text viewer window xbmc.executebuiltin("ActivateWindow(%d)" % (self.WINDOW, )) # get window self.win = xbmcgui.Window(self.WINDOW) # give window time to initialize xbmc.sleep(1000)
def window(key, value=None, clear=False, window_id=10000): ''' Get or set window properties. ''' window = xbmcgui.Window(window_id) if clear: LOG.debug("--[ window clear: %s ]", key) window.clearProperty(key.replace('.json', "").replace('.bool', "")) elif value is not None: if key.endswith('.json'): key = key.replace('.json', "") value = json.dumps(value) elif key.endswith('.bool'): key = key.replace('.bool', "") value = "true" if value else "false" window.setProperty(key, value) else: result = window.getProperty( key.replace('.json', "").replace('.bool', "")) if result: if key.endswith('.json'): result = json.loads(result) elif key.endswith('.bool'): result = result in ("true", "1") return result
def winprop(key, value=None, clear=False, window_id=10000): window = xbmcgui.Window(window_id) if clear: window.clearProperty(key.replace('.json', '').replace('.bool', '')) elif value is not None: if key.endswith('.json'): key = key.replace('.json', '') value = json.dumps(value) elif key.endswith('.bool'): key = key.replace('.bool', '') value = 'true' if value else 'false' window.setProperty(key, value) else: result = window.getProperty( key.replace('.json', '').replace('.bool', '')) if result: if key.endswith('.json'): result = json.loads(result) elif key.endswith('.bool'): result = result in ('true', '1') return result
def saveVolume(): json_query = '{"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["volume"]},"id":1}' json_response = (sendJSON(json_query)) if not json_response: return False restoreVolume = json_response.get('result',{}).get('volume',0) log('saveVolume, state = ' + str(restoreVolume)) xbmcgui.Window(10000).setProperty('%s.RESTORE'%ADDON_ID,str(restoreVolume)) return True
def __init__(self, *args, **kwargs): self.WINDOW = 10147 self.CONTROL_LABEL = 1 self.CONTROL_TEXTBOX = 5 xbmc.executebuiltin("ActivateWindow(%d)" % (self.WINDOW, )) self.win = xbmcgui.Window(self.WINDOW) xbmc.sleep(500) self.setControls()
def onInit(self): self.winid = xbmcgui.Window(xbmcgui.getCurrentWindowDialogId()) self.winid.setProperty('ss_time', 'okay' if REAL_SETTINGS.getSetting("Time") == 'true' else 'nope') self.myPlayer.play(self.buildPlaylist()) if saveVolume(): setVolume(int(REAL_SETTINGS.getSetting('SetVolume'))) setRepeat('all')
def __init__(self, *args, **kwargs): xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) if DISABLE_TRAKT: xbmcgui.Window(10000).setProperty('script.trakt.paused','true') self.playList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) self.fileCount = 0 self.cache = SimpleCache() self.myPlayer = Player() self.myPlayer.myBackground = self
def getProperty(key, id=10000): try: key = '%s.%s'%(ADDON_ID,key) value = xbmcgui.Window(id).getProperty(key) if value: log("globals: getProperty, key = " + key + ", value = " + value) return value except Exception as e: log("globals: getProperty, Failed! " + str(e), xbmc.LOGERROR) return ''
def setview(): skin = xbmc.getSkinDir().lower() win = xbmcgui.Window(xbmcgui.getCurrentWindowId()) viewtype = str(win.getFocusId()) addon.setSetting('setview', ';'.join([skin, viewtype])) addon.setSetting('customview', 'true') viewName = xbmc.getInfoLabel('Container.Viewmode') notify(i18n('dflt_view_set'), '{0} {1}'.format(i18n('dflt_set'), viewName)) xbmc.executebuiltin('Container.Refresh')
def manage_plex(context): try: with PlexManage(i18n('Manage myPlex'), window=xbmcgui.Window(10000)) as dialog: dialog.set_context(context) dialog.start() except AlreadyActiveException: pass except AttributeError: LOG.debug('Failed to load PlexManage ...')
def getAllListItems(): focusId = xbmcgui.Window().getFocusId() numItems = int('0%s' % xbmc.getInfoLabel('Container(%s).NumItems' % focusId)) items = [] for pos in range(1, numItems): item = getGuiListItem(focusId, pos) if item.get('Artist') and item.get('Title'): items.append(item) return items
def main(): if xbmc.getInfoLabel('Window(10000).Property(script.plex.service.started)'): # Prevent add-on updates from starting a new version of the addon return xbmcgui.Window(10000).setProperty('script.plex.service.started', '1') if xbmcaddon.Addon().getSetting('kiosk.mode') == 'true': xbmc.log('script.plex: Starting from service (Kiosk Mode)', xbmc.LOGINFO) xbmc.executebuiltin('RunScript(script.plex)')
def getCity(self, lat, lon): log("getCity, lat = %s, lon = %s" % (lat, lon)) '''{u'active': True, u'DMA': u'501', u'small_url': u'https://s3.us-east-2.amazonaws.com/static.locastnet.org/cities/new-york.jpg', u'large_url': u'https://s3.us-east-2.amazonaws.com/static.locastnet.org/cities/background/new-york.jpg', u'name': u'New York'}''' try: city = self.getURL(BASE_API + '/watch/dma/%s/%s' % (lat, lon), header=self.buildHeader()) if city and 'DMA' not in city: REAL_SETTINGS.setSetting('User_DMA', '0') REAL_SETTINGS.setSetting('User_City', 'Unknown') xbmcgui.Window(10000).setProperty('User_City', 'Unknown') okDisable(city.get('message')) return 'Unknown', 0 else: REAL_SETTINGS.setSetting('User_DMA', str(city['DMA'])) REAL_SETTINGS.setSetting('User_City', city['name']) xbmcgui.Window(10000).setProperty('User_City', str(city['name'])) except: okDisable(LANGUAGE(30013))
def onInit(self): '''Called after initialization, get all colors and build the listing''' with busy_dialog(): self.current_window = xbmcgui.Window( xbmcgui.getCurrentWindowDialogId()) self.colors_list = self.getControl(3110) # set header_label try: self.getControl(1).setLabel(self.header_label) except Exception: pass # get current color that is stored in the skin setting curvalue = "" curvalue_name = "" if self.skinstring: curvalue = xbmc.getInfoLabel("Skin.String(%s)" % self.skinstring) curvalue_name = xbmc.getInfoLabel("Skin.String(%s.name)" % self.skinstring) if self.win_property: curvalue = WINDOW.getProperty(self.win_property) curvalue_name = xbmc.getInfoLabel('%s.name)' % self.win_property) if curvalue: self.current_window.setProperty("colorstring", curvalue) if curvalue != curvalue_name: self.current_window.setProperty("colorname", curvalue_name) self.current_window.setProperty("current.colorstring", curvalue) if curvalue != curvalue_name: self.current_window.setProperty("current.colorname", curvalue_name) # load colors in the list self.load_colors_palette(self.active_palette) # focus the current color if self.current_window.getProperty("colorstring"): self.current_window.setFocusId(3010) else: # no color setup so we just focus the colorslist self.current_window.setFocusId(3110) self.colors_list.selectItem(0) self.current_window.setProperty( "colorstring", self.colors_list.getSelectedItem().getProperty( "colorstring")) self.current_window.setProperty( "colorname", self.colors_list.getSelectedItem().getLabel()) # set opacity slider if self.current_window.getProperty("colorstring"): self.set_opacity_slider()
def composite_playlist(context): play = False try: with CompositePlaylistWindow(context=context, window=xbmcgui.Window(10000)) as dialog: play = dialog.start() except AlreadyActiveException: pass except AttributeError: LOG.debug('Failed to load CompositePlaylistWindow ...') return play
def __init__(self, storage_id, window_id=10000): """ :type storage_id: str :type window_id: int """ self._id = storage_id self._window = xbmcgui.Window(window_id) try: self['__keys__'] except KeyError: self['__keys__'] = []
def done(title, dest, downloaded): playing = xbmc.Player().isPlaying() text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED') if len(text) > 0: text += '[CR]' if downloaded: text += '%s : %s' % (dest.rsplit( os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]') else: text += '%s : %s' % (dest.rsplit( os.sep)[-1], '[COLOR red]Download failed[/COLOR]') xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text) if (not downloaded) or (not playing): xbmcgui.Dialog().ok(title, text) xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
def setProperty(self, key, value): if self._closing: return if not self._winID: self._winID = xbmcgui.getCurrentWindowId() try: xbmcgui.Window(self._winID).setProperty(key, value) xbmcgui.WindowXMLDialog.setProperty(self, key, value) except RuntimeError: xbmc.log('kodigui.BaseDialog.setProperty: Missing window', xbmc.LOGDEBUG)
def run(self): while not MONITOR.abortRequested(): if xbmc.getCondVisibility('System.HasAddon(plugin.video.pseudotv.live)'): try: asset = json.loads(xbmcgui.Window(10000).getProperty(PROP_KEY)) except: asset = {} if self.chkVOD():# Build Recommend VOD asset['vod'] = [] #clear older list items = load(self.getDirs('plugin://%s'%(ADDON_ID),ADDON_VERSION)).get('result',{}).get('files',[]) for item in items: if item.get('filetype') == 'directory': label = '%s (%s)'%(item.get('label'),ADDON_NAME) plot = (item.get("plot","") or item.get("plotoutline","") or item.get("description","")) asset.setdefault('vod',[]).append({'type':'vod','name':label,'description':plot,'icon':LOGO,'path':item.get('file'),'id':ADDON_ID}) xbmcgui.Window(10000).setProperty('Last_VOD',str(time.time())) xbmcgui.Window(10000).setProperty(PROP_KEY, json.dumps(asset)) WAIT_TIME = 900 else: xbmcgui.Window(10000).clearProperty(PROP_KEY) WAIT_TIME = 300 if MONITOR.waitForAbort(WAIT_TIME): break
def onInit(self): self.winid = xbmcgui.Window(xbmcgui.getCurrentWindowDialogId()) self.winid.setProperty( 'unsplash_animation', 'okay' if REAL_SETTINGS.getSetting("Animate") == 'true' else 'nope') self.winid.setProperty( 'unsplash_time', 'okay' if REAL_SETTINGS.getSetting("Time") == 'true' else 'nope') self.winid.setProperty( 'unsplash_overlay', 'okay' if REAL_SETTINGS.getSetting("Overlay") == 'true' else 'nope') self.startRotation()
def __init__(self, *args, **kwargs): super(xbmcgui.WindowXMLDialog, self).__init__() self.action_exitkeys_id = [10, 13] self.win = xbmcgui.Window(10000) self.build_colors_list() self.result = -1 # check paths if xbmcvfs.exists( SKINCOLORFILE) and not xbmcvfs.exists(SKINCOLORFILES_PATH): xbmcvfs.mkdirs(SKINCOLORFILES_PATH) if not xbmcvfs.exists(COLORFILES_PATH): xbmcvfs.mkdirs(COLORFILES_PATH)