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


Python Settings.getBatchSize方法代码示例

本文整理汇总了Python中settings.Settings.getBatchSize方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getBatchSize方法的具体用法?Python Settings.getBatchSize怎么用?Python Settings.getBatchSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在settings.Settings的用法示例。


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

示例1: populateRadioStations

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getBatchSize [as 别名]
    def populateRadioStations(self):
        sonosDevice = Sonos.createSonosDevice()

        # Make sure a Sonos speaker was found
        if sonosDevice is not None:
            totalCollected = 0
            totalEntries = 1

            # Need to get all the tracks in batches
            while (totalCollected < totalEntries) and not self._listLimitReached(totalCollected):
                # Get the items from the sonos system
                list = None
                try:
                    list = sonosDevice.get_favorite_radio_stations(
                        start=totalCollected, max_items=Settings.getBatchSize()
                    )
                except:
                    log("SonosPlugin: %s" % traceback.format_exc(), xbmc.LOGERROR)
                    xbmcgui.Dialog().ok(__addon__.getLocalizedString(32068), __addon__.getLocalizedString(32071))
                    return

                # Processes the list returned from Sonos, creating the list display on the screen
                totalEntries = int(list["total"])
                log("SonosPlugin: Total Radio Station Matches %d" % totalEntries)
                numberReturned = list["returned"]
                log("SonosPlugin: Total Radio Stations in this batch %d" % numberReturned)

                # Makes sure some items are returned
                if numberReturned < 1:
                    numberReturned = len(list["favorites"])
                    if numberReturned < 1:
                        log("SonosPlugin: Zero items returned from request")
                        break

                for item in list["favorites"]:
                    # Add the radio station to the list
                    url = self._build_url(
                        {
                            "mode": "action",
                            "action": ActionManager.ACTION_RADIO_PLAY,
                            "itemId": item["uri"],
                            "title": item["title"],
                        }
                    )

                    li = xbmcgui.ListItem(item["title"], path=url, iconImage=MediaFiles.RadioStationIcon)
                    # Set the right click context menu for the ratio station
                    li.addContextMenuItems([], replaceItems=True)  # Clear the Context Menu
                    self._addPlayerToContextMenu(li)

                    xbmcplugin.addDirectoryItem(
                        handle=self.addon_handle, url=url, listitem=li, isFolder=False, totalItems=totalEntries
                    )

                # Add the number returned this time to the running total
                totalCollected = totalCollected + numberReturned
            del sonosDevice

        xbmcplugin.endOfDirectory(self.addon_handle)
开发者ID:noba3,项目名称:KoTos,代码行数:61,代码来源:plugin.py

示例2: processFolderMessage

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getBatchSize [as 别名]
    def processFolderMessage(self, folderName, subCategory=""):
        sonosDevice = Sonos.createSonosDevice()

        # Make sure a Sonos speaker was found
        if sonosDevice is not None:
            # Process the sub-category
            if subCategory is None:
                subCategory = ""

            totalCollected = 0
            totalEntries = 1

            isFirstItem = True

            # Need to get all the tracks in batches
            while (totalCollected < totalEntries) and not self._listLimitReached(totalCollected):
                # make the call to get the tracks in batches of 100

                # Get the items from the sonos system
                list = None
                try:
                    if (subCategory is None) or (subCategory == ""):
                        list = sonosDevice.music_library.get_music_library_information(
                            folderName, totalCollected, Settings.getBatchSize(), True
                        )
                    else:
                        # Make sure the sub category is valid for the message, escape invalid characters
                        # subCategory = urllib.quote(subCategory)
                        # Call the browse version
                        list = sonosDevice.music_library.browse_by_idstring(
                            folderName, subCategory, totalCollected, Settings.getBatchSize(), True
                        )
                except:
                    log("SonosPlugin: %s" % traceback.format_exc(), xbmc.LOGERROR)
                    xbmcgui.Dialog().ok(
                        __addon__.getLocalizedString(32068),
                        __addon__.getLocalizedString(32069) % (folderName, subCategory),
                    )
                    return

                # Processes the list returned from Sonos, creating the list display on the screen
                totalEntries = list.total_matches
                log("SonosPlugin: Total %s Matches %d" % (folderName, totalEntries))
                numberReturned = list.number_returned
                log("SonosPlugin: Total %s in this batch %d" % (folderName, numberReturned))

                # Makes sure some items are returned
                if numberReturned < 1:
                    numberReturned = len(list)
                    if numberReturned < 1:
                        log("SonosPlugin: Zero items returned from request")
                        break

                for item in list:
                    # Check if this item is a track of a directory
                    if isinstance(item, soco.data_structures.DidlMusicTrack):
                        self._addTrack(item, totalEntries, folderName)
                    else:
                        # Check for the special case where there is an "All" first in the list
                        # For this the id and parent values are the same.  The All item
                        # is a special case and does not handle like a normal directory
                        if ("sameArtist" in item.item_class) or ("albumlist" in item.item_class):
                            log('SonosPlugin: Skipping "All" item for %s' % item.title)
                            isFirstItem = False
                            continue

                        # Check to see if we are dealing with a sonos playlist
                        if isinstance(item, soco.data_structures.DidlPlaylistContainer):
                            # Will need to do the search by ID for playlists as the text method
                            # does not work
                            self._addDirectory(item, folderName, totalEntries, subCategory, item.item_id)
                        else:
                            self._addDirectory(item, folderName, totalEntries, subCategory)
                    # No longer the first item
                    isFirstItem = False  # noqa PEP8

                # Add the number returned this time to the running total
                totalCollected = totalCollected + numberReturned
            del sonosDevice

        xbmcplugin.endOfDirectory(self.addon_handle)
开发者ID:noba3,项目名称:KoTos,代码行数:83,代码来源:plugin.py

示例3: populateQueueList

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getBatchSize [as 别名]
    def populateQueueList(self):
        sonosDevice = Sonos.createSonosDevice()

        # Make sure a Sonos speaker was found
        if sonosDevice is not None:
            totalCollected = 0
            numberReturned = Settings.getBatchSize()

            # Need to get all the tracks in batches
            # Only get the next batch if all the items requested were in the last batch
            while (numberReturned == Settings.getBatchSize()) and not self._listLimitReached(totalCollected):
                # Get the items from the sonos system
                list = None
                try:
                    list = sonosDevice.get_queue(totalCollected, Settings.getBatchSize(), True)
                except:
                    log("SonosPlugin: %s" % traceback.format_exc(), xbmc.LOGERROR)
                    xbmcgui.Dialog().ok(__addon__.getLocalizedString(32068), __addon__.getLocalizedString(32070))
                    return

                # Processes the list returned from Sonos, creating the list display on the screen
                numberReturned = len(list)
                log("SonosPlugin: Total queue entries in this batch %d" % numberReturned)

                itemNum = 0

                for item in list:
                    # Get a suitable display title
                    displayTitle = None
                    if (item.creator is not None) and (item.creator != ""):
                        displayTitle = "%s - %s" % (item.title, item.creator)
                    else:
                        displayTitle = item.title

                    # Create the list item for the track
                    if (
                        hasattr(item, "album_art_uri")
                        and (item.album_art_uri is not None)
                        and (item.album_art_uri != "")
                    ):
                        li = xbmcgui.ListItem(
                            displayTitle, iconImage=item.album_art_uri, thumbnailImage=item.album_art_uri
                        )
                    else:
                        li = xbmcgui.ListItem(displayTitle, iconImage=MediaFiles.TracksIcon)
                    # Set addition information about the track - will be seen in info view
                    li.setInfo("music", {"title": item.title, "artist": item.creator, "album": item.album})

                    # Create the action to be performed when clicking a queue item
                    url = self._build_url(
                        {"mode": "action", "action": ActionManager.ACTION_QUEUE_PLAY_ITEM, "itemId": itemNum}
                    )

                    # Add the context menu for the queue
                    self._addQueueContextMenu(li, itemNum + totalCollected)
                    itemNum = itemNum + 1

                    xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)

                totalCollected = totalCollected + numberReturned
            del sonosDevice

        xbmcplugin.endOfDirectory(self.addon_handle)
开发者ID:noba3,项目名称:KoTos,代码行数:65,代码来源:plugin.py


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