Python xbmcgui.getCurrentWindowId() Examples

The following are 18 code examples of xbmcgui.getCurrentWindowId(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmcgui , or try the search function .
Example #1
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def get_cached_item(self, cache_id):
        """Returns an item from the in memory cache

        Parameters
        ----------
        cache_id : :obj:`str`
            ID of the cache entry

        Returns
        -------
        mixed
            Contents of the requested cache item or none
        """
        ret = None
        current_window = xbmcgui.getCurrentWindowId()
        window = xbmcgui.Window(current_window)
        try:
            cached_items = pickle.loads(window.getProperty('memcache').encode('latin-1'))
            ret = cached_items.get(cache_id)
        except (EOFError, UnicodeDecodeError) as e:
            self.nx_common.log(msg='memcache: get_cached_items failed' + str(e))
            ret = None
        return ret 
Example #2
Source File: DialogDownloadProgress.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def setupWindow(self):
        error = 0
        # get the id for the current 'active' window as an integer.
        # http://wiki.xbmc.org/index.php?title=Window_IDs
        try:
            currentWindowId = xbmcgui.getCurrentWindowId()
        except:
            currentWindowId = self.window

        if hasattr(currentWindowId, "__int__") and currentWindowId != self.windowId:
            self.removeControls()
            self.windowId = currentWindowId
            self.window = xbmcgui.Window(self.windowId)
            self.initialize()

        if not self.window or not hasattr(self.window, "addControl"):
            self.removeControls()
            error = 1
        if error:
            raise xbmcguiWindowError("xbmcgui.Window(%s)" % repr(currentWindowId))

        #self.window.setProperty("DialogDownloadProgress.IsAlive", "true") 
Example #3
Source File: PostPlayInfo.py    From service.nextup.notification with GNU General Public License v2.0 6 votes vote down vote up
def onInit(self):
        xbmc.log("PostPlayInfo ->  onInit called",level=xbmc.LOGNOTICE)
        self.upNextControl = self.getControl(self.NEXTUP_LIST_ID)
        self.spoilersControl = self.getControl(self.SPOILERS_BUTTON_ID)
        self._winID = xbmcgui.getCurrentWindowId()
        playMode = self.addonSettings.getSetting("autoPlayMode")
        if playMode == "1":
            self.playAutomatically = False

        self.setInfo()
        self.setPreviousInfo()
        self.fillUpNext()
        self.prepareSpoilerButton()
        self.prepareStillWatching()
        self.startTimer()

        if self.item is not None:
            self.setFocusId(self.NEXT_BUTTON_ID)
        else:
            self.setFocusId(self.PREV_BUTTON_ID)

        xbmcgui.Window(10000).clearProperty("NextUpNotification.AutoPlayed")

        xbmc.log("PostPlayInfo ->  onInit completed",level=xbmc.LOGNOTICE) 
Example #4
Source File: loop.py    From script.service.kodi.callbacks with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        lastwindowid = xbmcgui.getCurrentWindowId()
        lastprofile = getProfileString()
        laststereomode = getStereoscopicMode()
        interval = self.interval
        firstloop = True
        starttime = time.time()
        while not self.abort_evt.is_set():

            self._checkIdle()

            newprofile = getProfileString()
            if newprofile != lastprofile:
                self.publish(Message(Topic('onProfileChange'), profilePath=newprofile))
                lastprofile = newprofile

            newstereomode = getStereoscopicMode()
            if newstereomode != laststereomode:
                self.publish(Message(Topic('onStereoModeChange'), stereoMode=newstereomode))
                laststereomode = newstereomode

            newwindowid = xbmcgui.getCurrentWindowId()
            if newwindowid != lastwindowid:
                if lastwindowid in self.closewindowsids.keys():
                    self.publish(Message(Topic('onWindowClose', self.closewindowsids[lastwindowid])))
                if newwindowid in self.openwindowids:
                    self.publish(Message(Topic('onWindowOpen', self.openwindowids[newwindowid])))
                lastwindowid = newwindowid

            if firstloop:
                endtime = time.time()
                interval = int(interval - (endtime - starttime) * 1000)
                interval = max(5, interval)
                firstloop = False
            xbmc.sleep(interval)
        del self.player 
Example #5
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 5 votes vote down vote up
def invalidate_memcache(self):
        """Invalidates the memory cache"""
        current_window = xbmcgui.getCurrentWindowId()
        window = xbmcgui.Window(current_window)
        try:
            window.setProperty('memcache', pickle.dumps({}, protocol=0).decode('latin-1'))
        except EOFError:
            self.nx_common.log(msg='invalidate_memcache failed')
            pass 
Example #6
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 5 votes vote down vote up
def setup_memcache(self):
        """Sets up the memory cache if not existant"""
        current_window = xbmcgui.getCurrentWindowId()
        window = xbmcgui.Window(current_window)
        try:
            cached_items = window.getProperty('memcache')
            # no cache setup yet, create one
            if len(cached_items) >= 1:
                return
        except (EOFError, UnicodeDecodeError):
            self.nx_common.log(msg='setup_memcache failed, recreating')
            pass
        window.setProperty('memcache', pickle.dumps({}, protocol=0).decode('latin-1')) 
Example #7
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 5 votes vote down vote up
def get_main_menu_selection(self):
        """Gets the persisted chosen main menu entry from memory

        Returns
        -------
        :obj:`str`
            The last chosen main menu entry
        """
        current_window = xbmcgui.getCurrentWindowId()
        window = xbmcgui.Window(current_window)
        return window.getProperty('main_menu_selection') 
Example #8
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 5 votes vote down vote up
def set_main_menu_selection(self, type):
        """Persist the chosen main menu entry in memory

        Parameters
        ----------
        type : :obj:`str`
            Selected menu item
        """
        current_window = xbmcgui.getCurrentWindowId()
        xbmcgui.Window(current_window).setProperty('main_menu_selection', type) 
Example #9
Source File: monitor.py    From plugin.video.surveillanceroom with GNU General Public License v3.0 5 votes vote down vote up
def checkWindowID(self):
        current_dialog_id = getCurrentWindowDialogId()
        current_window_id = getCurrentWindowId()

        for window_id in self._preview_disabled_window_id:
            if current_window_id == window_id or current_dialog_id == window_id:
                return True
        return False


    # Function that determines if a preview is allowed to be shown considering the global state 
Example #10
Source File: PostPlayInfo.py    From service.nextup.notification with GNU General Public License v2.0 5 votes vote down vote up
def setProperty(self, key, value):

        if not self._winID:
            self._winID = xbmcgui.getCurrentWindowId()

        try:
            xbmcgui.Window(self._winID).setProperty(key, value)
            xbmcgui.WindowXML.setProperty(self, key, value)
        except:
            pass 
Example #11
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def run(uris, title):
    init_run()

    time.sleep(1)
    cwnd = xbmcgui.getCurrentWindowId()
    
    uri = uris
    uril = uris.split('@')
    titles = []
    for item in uril:
        titles.append(get_addon_id(item))
        
    if (SUPPORT_US == "true") and (title) and (cwnd != 10000):
            titles.append("Search with United Search ...")  
            uril.append("plugin://plugin.video.united.search/?action=search&keyword={0}".format(title))
        
    ret = 0
    if len(uril) > 0:
        if len(uril) > 1:
            ret = xbmcgui.Dialog().select("Select source", titles)
        if ret >= 0:
            uri = uril[ret]
        else:
            return
    else:
        return

    playable = ('#' == uri[0])
    uri = uri.replace('#', '')
    if (playable == True):
        run_as_content(uri)
    else: 
        if (cwnd == 10000): 
            xbmc.executebuiltin("ActivateWindow({0}, {1})".format("videos", uri))
        else:
            xbmc.executebuiltin("Container.Update({0})".format(uri))
    time.sleep(0.1) 
Example #12
Source File: ts.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def onPlayBackStarted(self):
        pass
        LogToXBMC('%s %s %s' % (xbmcgui.getCurrentWindowId(), self.amalker, self.getPlayingFile()))
        if not self.amalker and self.winmode:
            self.parent.player.show()
            pass
        elif self.amalker:
            pass
            LogToXBMC('SHOW ADS Window')
            self.parent.amalkerWnd.show()
            LogToXBMC('END SHOW ADS Window') 
Example #13
Source File: addon.py    From script.module.clouddrive.common with GNU General Public License v3.0 5 votes vote down vote up
def list_accounts(self):
        accounts = self.get_accounts(with_format=True)
        listing = []
        for account_id in accounts:
            account = accounts[account_id]
            size = len(account['drives'])
            for drive in account['drives']:
                context_options = []
                params = {'action':'_search', 'content_type': self._content_type, 'driveid': drive['id']}
                cmd = 'ActivateWindow(%d,%s?%s)' % (xbmcgui.getCurrentWindowId(), self._addon_url, urllib.urlencode(params))
                context_options.append((self._common_addon.getLocalizedString(32039), cmd))
                params['action'] = '_remove_account'
                context_options.append((self._common_addon.getLocalizedString(32006), 'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')'))
                if size > 1:
                    params['action'] = '_remove_drive'
                    cmd =  'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')'
                    context_options.append((self._common_addon.getLocalizedString(32007), cmd))
                list_item = xbmcgui.ListItem(drive['display_name'])
                list_item.addContextMenuItems(context_options)
                params = {'action':'_list_drive', 'content_type': self._content_type, 'driveid': drive['id']}
                url = self._addon_url + '?' + urllib.urlencode(params)
                listing.append((url, list_item, True))
        list_item = xbmcgui.ListItem(self._common_addon.getLocalizedString(32005))
        params = {'action':'_add_account', 'content_type': self._content_type}
        url = self._addon_url + '?' + urllib.urlencode(params)
        listing.append((url, list_item))
        xbmcplugin.addDirectoryItems(self._addon_handle, listing, len(listing))
        xbmcplugin.endOfDirectory(self._addon_handle, True) 
Example #14
Source File: addon.py    From script.module.clouddrive.common with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self._addon = KodiUtils.get_addon()
        self._addonid = self._addon.getAddonInfo('id')
        self._addon_name = self._addon.getAddonInfo('name')
        self._addon_url = sys.argv[0]
        self._addon_version = self._addon.getAddonInfo('version')
        self._common_addon_id = 'script.module.clouddrive.common'
        self._common_addon = KodiUtils.get_addon(self._common_addon_id)
        self._common_addon_version = self._common_addon.getAddonInfo('version')
        self._dialog = xbmcgui.Dialog()
        self._profile_path = Utils.unicode(KodiUtils.translate_path(self._addon.getAddonInfo('profile')))
        self._progress_dialog = DialogProgress(self._addon_name)
        self._progress_dialog_bg = DialogProgressBG(self._addon_name)
        self._export_progress_dialog_bg = DialogProgressBG(self._addon_name)
        self._system_monitor = KodiUtils.get_system_monitor()
        self._account_manager = AccountManager(self._profile_path)
        self._pin_dialog = None
        self.iskrypton = KodiUtils.get_home_property('iskrypton') == 'true'
        
        if len(sys.argv) > 1:
            self._addon_handle = int(sys.argv[1])
            self._addon_params = urlparse.parse_qs(sys.argv[2][1:])
            for param in self._addon_params:
                self._addon_params[param] = self._addon_params.get(param)[0]
            self._content_type = Utils.get_safe_value(self._addon_params, 'content_type')
            if not self._content_type:
                wid = xbmcgui.getCurrentWindowId()
                if wid == 10005 or wid == 10500 or wid == 10501 or wid == 10502:
                    self._content_type = 'audio'
                elif wid == 10002:
                    self._content_type = 'image'
                else:
                    self._content_type = 'video'
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) 
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_SIZE )
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DATE )
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION ) 
Example #15
Source File: utils.py    From script.module.clouddrive.common with GNU General Public License v3.0 5 votes vote down vote up
def get_current_window_id():
        import xbmcgui
        return xbmcgui.getCurrentWindowId() 
Example #16
Source File: main.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 5 votes vote down vote up
def focus(i):

    #TODO find way to check this has worked (clist.getSelectedPosition returns -1)
    xbmc.sleep(int(plugin.get_setting('scroll.ms') or "0"))
    #TODO deal with hidden ..
    win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
    cid = win.getFocusId()
    if cid:
        clist = win.getControl(cid)
        if clist:
            try: clist.selectItem(i)
            except: pass 
Example #17
Source File: gui.py    From xbmc.service.pushbullet with GNU General Public License v3.0 5 votes vote down vote up
def onInit(self):
        self._winID = xbmcgui.getCurrentWindowId() 
Example #18
Source File: ts.py    From ru with GNU General Public License v2.0 4 votes vote down vote up
def play_url_ind(self, index=0, title='', icon=None, thumb=None, torrent=None, mode=None):
        if self.last_error:
            return
        if torrent or self.torrent == '':
            self.torrent = torrent
            self.mode = mode
        if not self.torrent or self.torrent == '':
            self.parent.showStatus('Нечего проигрывать')
            return
        spons = ''
        if self.mode != TSengine.MODE_PID:
            spons = ' 0 0 0'
        comm='START '+self.mode+ ' ' + self.torrent + ' '+ str(index) + spons
        LogToXBMC("Запуск торрента")
        self.stop()
        xbmc.sleep(4)
        self.sendCommand(comm)
        if self.parent: self.parent.showStatus("Запуск торрента")
        self.Wait(TSMessage.START)
        msg = self.thr.getTSMessage()
        if msg.getType() == TSMessage.START:
            try:
                _params = msg.getParams()
                if not _params.has_key('url'):
                    if self.parent: self.parent.showStatus("Неверный ответ от TS. Операция прервана")
                    raise Exception('Incorrect msg from TS %s' % msg.getType())

                self.amalker = _params.has_key('ad') and not _params.has_key('interruptable')
                self.link = _params['url'].replace('127.0.0.1', self.server_ip).replace('6878', self.webport)
                LogToXBMC('Преобразование ссылки: %s' % self.link)
                self.title = title
                self.icon = icon
                self.playing = True
                
                self.thr.msg = TSMessage()
                if self.amalker:
                    self.parent.showStatus('Рекламный ролик')
                #    self.parent.player.doModal()
                #else:
                #    self.parent.amalker.show()
                LogToXBMC('Первый запуск. Окно = %s. Реклама = %s' % (xbmcgui.getCurrentWindowId(), self.amalker))
                self.icon = icon
                self.thumb = thumb
                lit= xbmcgui.ListItem(title, iconImage = icon, thumbnailImage = thumb)
                if self.amalker or self.winmode:
                    self.play(self.link, lit, windowed = True)
                else:
                    self.play(self.link, lit)
                self.playing = True
                self.paused = False
                self.loop()
            except Exception, e:
                LogToXBMC(e, 2)
                self.last_error = e
                if self.parent: self.parent.showStatus("Ошибка. Операция прервана")
                self.tsstop()