当前位置: 首页>>代码示例>>Python>>正文


Python utils.window函数代码示例

本文整理汇总了Python中utils.window函数的典型用法代码示例。如果您正苦于以下问题:Python window函数的具体用法?Python window怎么用?Python window使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了window函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: watchlater

def watchlater():
    """
    Listing for plex.tv Watch Later section (if signed in to plex.tv)
    """
    if window('plex_token') == '':
        log.error('No watch later - not signed in to plex.tv')
        return xbmcplugin.endOfDirectory(HANDLE, False)
    if window('plex_restricteduser') == 'true':
        log.error('No watch later - restricted user')
        return xbmcplugin.endOfDirectory(HANDLE, False)

    xml = downloadutils.DownloadUtils().downloadUrl(
        'https://plex.tv/pms/playlists/queue/all',
        authenticate=False,
        headerOptions={'X-Plex-Token': window('plex_token')})
    if xml in (None, 401):
        log.error('Could not download watch later list from plex.tv')
        return xbmcplugin.endOfDirectory(HANDLE, False)

    log.info('Displaying watch later plex.tv items')
    xbmcplugin.setContent(HANDLE, 'movies')
    for item in xml:
        __build_item(item)

    xbmcplugin.endOfDirectory(
        handle=HANDLE,
        cacheToDisc=settings('enableTextureCache') == 'true')
开发者ID:RickDB,项目名称:PlexKodiConnect,代码行数:27,代码来源:entrypoint.py

示例2: onPlayBackStopped

 def onPlayBackStopped( self ):
     # Will be called when user stops xbmc playing a file
     self.logMsg("ONPLAYBACK_STOPPED", 2)
     utils.window('emby_customPlaylist', clear=True)
     utils.window('emby_playbackProps', clear=True)
     self.logMsg("Clear playlist properties.", 1)
     self.stopAll()
开发者ID:Alwin-Hummels,项目名称:plugin.video.emby,代码行数:7,代码来源:player.py

示例3: __init__

 def __init__(self, header, errors):
     '''
     Sets title of the dialog and fills the tree with information stored
     in given list of ErrorBox instances.
     '''
     QtCore.QObject.__init__(self)
     elements = loadUi(self._DIALOG_UI, parent=window())
     self._dialog = elements["dialog"]
     self._dialog.setWindowTitle(header)
     tree = elements["treeWidgetErrors"]
     items = []
     for error in errors:
         item = QtGui.QTreeWidgetItem(tree)
         infos = []
         fields = vars(error)
         for name in sorted(fields):
             if name != "traceback":
                 infos.append(fields[name])
         item.setText(0, ", ".join(infos))
         QtGui.QTreeWidgetItem(item, [error.traceback])
         item.setExpanded(True)
         items.append(item)
     tree.resizeColumnToContents(0)
     size = QtCore.QSize(min(window().size().width(),
                             tree.columnWidth(0) + 40),
                         min(window().size().height(),
                             self._dialog.size().height()))
     self._dialog.resize(size)
     for item in items:
         item.setExpanded(False)
开发者ID:mlyko,项目名称:tadek-ui,代码行数:30,代码来源:testdialogs.py

示例4: externalSubs

    def externalSubs(self, playurl):

        externalsubs = []
        mapping = {}

        itemid = self.API.getRatingKey()
        mediastreams = self.API.getMediaStreams()

        kodiindex = 0
        for stream in mediastreams:

            index = stream['Index']
            # Since Emby returns all possible tracks together, have to pull only external subtitles.
            # IsTextSubtitleStream if true, is available to download from emby.
            if (stream['Type'] == "Subtitle" and 
                    stream['IsExternal'] and stream['IsTextSubtitleStream']):

                # Direct stream
                url = ("%s/Videos/%s/%s/Subtitles/%s/Stream.srt"
                        % (self.server, itemid, itemid, index))
                
                # map external subtitles for mapping
                mapping[kodiindex] = index
                externalsubs.append(url)
                kodiindex += 1
        
        mapping = json.dumps(mapping)
        utils.window('emby_%s.indexMapping' % playurl, value=mapping)

        return externalsubs
开发者ID:gdachs,项目名称:PlexKodiConnect,代码行数:30,代码来源:playbackutils.py

示例5: _action_menu

    def _action_menu(self):

        selected = self._selected_option

        if selected == OPTIONS['Transcode']:
            window('plex_forcetranscode', value='true')
            self._PMS_play()

        elif selected == OPTIONS['PMS_Play']:
            self._PMS_play()

        # elif selected == OPTIONS['Refresh']:
        #     self.emby.refreshItem(self.item_id)

        # elif selected == OPTIONS['AddFav']:
        #     self.emby.updateUserRating(self.item_id, favourite=True)

        # elif selected == OPTIONS['RemoveFav']:
        #     self.emby.updateUserRating(self.item_id, favourite=False)

        # elif selected == OPTIONS['RateSong']:
        #     self._rate_song()

        elif selected == OPTIONS['Addon']:
            xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')

        elif selected == OPTIONS['Delete']:
            self._delete_item()
开发者ID:RickDB,项目名称:PlexKodiConnect,代码行数:28,代码来源:context_entry.py

示例6: setUserPref

 def setUserPref(self):
     log.debug('Setting user preferences')
     # Only try to get user avatar if there is a token
     if self.currToken:
         url = PlexAPI.PlexAPI().GetUserArtworkURL(self.currUser)
         if url:
             window('PlexUserImage', value=url)
开发者ID:RickDB,项目名称:PlexKodiConnect,代码行数:7,代码来源:userclient.py

示例7: getXArgsDeviceInfo

def getXArgsDeviceInfo(options=None):
    """
    Returns a dictionary that can be used as headers for GET and POST
    requests. An authentication option is NOT yet added.

    Inputs:
        options:        dictionary of options that will override the
                        standard header options otherwise set.
    Output:
        header dictionary
    """
    xargs = {
        'Accept': '*/*',
        'Connection': 'keep-alive',
        "Content-Type": "application/x-www-form-urlencoded",
        # "Access-Control-Allow-Origin": "*",
        # 'X-Plex-Language': 'en',
        'X-Plex-Device': v.ADDON_NAME,
        'X-Plex-Client-Platform': v.PLATFORM,
        'X-Plex-Device-Name': v.DEVICENAME,
        'X-Plex-Platform': v.PLATFORM,
        # 'X-Plex-Platform-Version': 'unknown',
        # 'X-Plex-Model': 'unknown',
        'X-Plex-Product': v.ADDON_NAME,
        'X-Plex-Version': v.ADDON_VERSION,
        'X-Plex-Client-Identifier': getDeviceId(),
        'X-Plex-Provides': 'client,controller,player,pubsub-player',
    }
    if window('pms_token'):
        xargs['X-Plex-Token'] = window('pms_token')
    if options is not None:
        xargs.update(options)
    return xargs
开发者ID:RickDB,项目名称:PlexKodiConnect,代码行数:33,代码来源:clientinfo.py

示例8: _report_progress

    def _report_progress(self):
        # Update and report playback progress
        kodi_player = self.kodi_player
        try:
            play_time = kodi_player.getTime()
            filename = kodi_player.currentFile

            # Update positionticks
            if filename in kodi_player.played_info:
                kodi_player.played_info[filename]['currentPosition'] = play_time

            difference = datetime.today() - self.last_progress
            difference_seconds = difference.seconds

            # Report progress to Emby server
            if difference_seconds > 3:
                kodi_player.reportPlayback()
                self.last_progress = datetime.today()

            elif window('emby_command') == "true":
                # Received a remote control command that
                # requires updating immediately
                window('emby_command', clear=True)
                kodi_player.reportPlayback()
                self.last_progress = datetime.today()

        except Exception as error:
            log.exception(error)
开发者ID:kravone,项目名称:plugin.video.emby,代码行数:28,代码来源:service_entry.py

示例9: getDeviceId

    def getDeviceId(self):

        clientId = utils.window('emby_deviceId')
        if clientId:
            return clientId

        addon_path = self.addon.getAddonInfo('path').decode('utf-8')
        GUID_file = xbmc.translatePath("%s\machine_guid" % addon_path).decode('utf-8')

        try:
            GUID = open(GUID_file)
        
        except IOError: # machine_guid does not exists.
            clientId = str("%012X" % uuid4())
            GUID = open(GUID_file, 'w')
            GUID.write(clientId)

        else: # machine_guid already exists. Get guid.
            clientId = GUID.read()
        
        finally:
            GUID.close()

        self.logMsg("DeviceId loaded: %s" % clientId, 1)
        utils.window('emby_deviceId', value=clientId)
        
        return clientId
开发者ID:angelblue05,项目名称:plugin.video.emby,代码行数:27,代码来源:clientinfo.py

示例10: __init__

    def __init__(self):

        self.__dict__ = self._shared_state

        client_info = clientinfo.ClientInfo()
        self.emby = embyserver.Read_EmbyServer()

        version = client_info.get_version()
        device_name = client_info.get_device_name()
        device_id = client_info.get_device_id()
        self._connect = connectionmanager.ConnectionManager(appName="Kodi",
                                                            appVersion=version,
                                                            deviceName=device_name,
                                                            deviceId=device_id)
        path = xbmc.translatePath(
                   "special://profile/addon_data/plugin.video.emby/").decode('utf-8')

        if not xbmcvfs.exists(path):
            xbmcvfs.mkdirs(path)

        self._connect.setFilePath(path)

        if window('emby_state.json'):
            self.state = window('emby_state.json')

        elif not self.state:
            self.state = self._connect.connect()
            log.info("Started with: %s", self.state)
            window('emby_state.json', value=self.state)
开发者ID:kravone,项目名称:plugin.video.emby,代码行数:29,代码来源:connectmanager.py

示例11: setUserPref

 def setUserPref(self):
     self.logMsg('Setting user preferences', 0)
     # Only try to get user avatar if there is a token
     if self.currToken:
         url = PlexAPI.PlexAPI().GetUserArtworkURL(self.currUser)
         if url:
             utils.window('EmbyUserImage', value=url)
开发者ID:gdachs,项目名称:PlexKodiConnect,代码行数:7,代码来源:userclient.py

示例12: play_all

 def play_all(self):
     """
     Play all items contained in the xml passed in. Called by Plex Companion
     """
     log.info("Playbackutils play_all called")
     window('plex_playbackProps', value="true")
     self.currentPosition = 0
     for item in self.xml:
         api = API(item)
         successful = True
         if api.getType() == v.PLEX_TYPE_CLIP:
             self.add_trailer(item)
         else:
             with Get_Plex_DB() as plex_db:
                 db_item = plex_db.getItem_byId(api.getRatingKey())
             if db_item is not None:
                 successful = add_item_to_kodi_playlist(
                     self.playqueue,
                     self.currentPosition,
                     kodi_id=db_item[0],
                     kodi_type=db_item[4])
                 if successful is True:
                     self.currentPosition += 1
                     if len(item[0]) > 1:
                         self.add_part(item,
                                       api,
                                       db_item[0],
                                       db_item[4])
             else:
                 # Item not in Kodi DB
                 self.add_trailer(item)
         if successful is True:
             self.playqueue.items[self.currentPosition - 1].ID = item.get(
                 '%sItemID' % self.playqueue.kind)
开发者ID:RickDB,项目名称:PlexKodiConnect,代码行数:34,代码来源:playbackutils.py

示例13: run

    def run(self):

        # websocket.enableTrace(True)
        user_id = window('emby_currUser')
        server = window('emby_server%s' % user_id)
        token = window('emby_accessToken%s' % user_id)
        # Get the appropriate prefix for the websocket
        if "https" in server:
            server = server.replace('https', "wss")
        else:
            server = server.replace('http', "ws")

        websocket_url = "%s?api_key=%s&deviceId=%s" % (server, token, self.device_id)
        log.info("websocket url: %s", websocket_url)

        self._client = websocket.WebSocketApp(websocket_url,
                                              on_message=self.on_message,
                                              on_error=self.on_error,
                                              on_close=self.on_close)
        self._client.on_open = self.on_open
        log.warn("----===## Starting WebSocketClient ##===----")

        while not self.monitor.abortRequested():

            if window('emby_online') == "true":
                self._client.run_forever(ping_interval=10)

            if self._stop_websocket:
                break

            if self.monitor.waitForAbort(5):
                # Abort was requested, exit
                break

        log.warn("##===---- WebSocketClient Stopped ----===##")
开发者ID:kravone,项目名称:plugin.video.emby,代码行数:35,代码来源:websocket_client.py

示例14: getPlayUrlNew

    def getPlayUrlNew(self):
        '''
            New style to retrieve the best playback method based on sending the profile to the server
            Based on capabilities the correct path is returned, including livestreams that need to be opened by the server
            TODO: Close livestream if needed (RequiresClosing in livestream source)
        '''
        playurl = None
        pbinfo = self.getPlaybackInfo()
        if pbinfo:
            xbmc.log("getPlayUrl pbinfo: %s" %(pbinfo))
            
            if pbinfo["Protocol"] == "SupportsDirectPlay":
                playmethod = "DirectPlay"
            elif pbinfo["Protocol"] == "SupportsDirectStream":
                playmethod = "DirectStream"
            elif pbinfo.get('LiveStreamId'):
                playmethod = "LiveStream"
            else:
                playmethod = "Transcode"

            playurl = pbinfo["Path"]
            xbmc.log("getPlayUrl playmethod: %s - playurl: %s" %(playmethod, playurl))
            window('emby_%s.playmethod' % playurl, value=playmethod)
            if pbinfo["RequiresClosing"] and pbinfo.get('LiveStreamId'):
                window('emby_%s.livestreamid' % playurl, value=pbinfo["LiveStreamId"])

        return playurl
开发者ID:kravone,项目名称:plugin.video.emby,代码行数:27,代码来源:playutils.py

示例15: getPlayerProperties

    def getPlayerProperties(self, playerid):
        info = {}
        try:
            # get info from the player
            props = self.js.jsonrpc("Player.GetProperties", {"playerid": playerid, "properties": ["time", "totaltime", "speed", "shuffled", "repeat"]})
            self.logMsg(self.js.jsonrpc("Player.GetItem", {"playerid": playerid, "properties": ["file", "showlink", "episode", "season"]}), 2)
            info['time'] = timeToMillis(props['time'])
            info['duration'] = timeToMillis(props['totaltime'])
            info['state'] = ("paused", "playing")[int(props['speed'])]
            info['shuffle'] = ("0","1")[props.get('shuffled', False)]
            info['repeat'] = pf.getPlexRepeat(props.get('repeat'))
            # New PMS playQueue attributes
            cf = self.xbmcplayer.getPlayingFile()
            info['playQueueID'] = window('playQueueID')
            info['playQueueVersion'] = window('playQueueVersion')
            info['playQueueItemID'] = window('plex_%s.playQueueItemID' % cf)
            info['guid'] = window('plex_%s.guid' % cf)

        except:
            info['time'] = 0
            info['duration'] = 0
            info['state'] = "stopped"
            info['shuffle'] = False
        # get the volume from the application
        info['volume'] = self.volume
        info['mute'] = self.mute

        return info
开发者ID:aglv,项目名称:PlexKodiConnect,代码行数:28,代码来源:subscribers.py


注:本文中的utils.window函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。