コード例 #1
0
    def items(self):
        if self._items is None:
            if self._data is not None:
                self._items = [
                    plexobjects.buildItem(self._server,
                                          elem,
                                          self._initpath,
                                          container=self._container)
                    for elem in self._data
                ]
            else:
                self._items = []

        return self._items
コード例 #2
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def init(self, data):
        self.items = []

        container = plexobjects.PlexContainer(data, self.key, self.server,
                                              self.key or '')

        if self.type == 'genre':
            self.items = [
                media.Genre(elem,
                            initpath='/hubs',
                            server=self.server,
                            container=container) for elem in data
            ]
        elif self.type == 'director':
            self.items = [
                media.Director(elem,
                               initpath='/hubs',
                               server=self.server,
                               container=container) for elem in data
            ]
        elif self.type == 'actor':
            self.items = [
                media.Role(elem,
                           initpath='/hubs',
                           server=self.server,
                           container=container) for elem in data
            ]
        else:
            for elem in data:
                try:
                    self.items.append(
                        plexobjects.buildItem(self.server,
                                              elem,
                                              '/hubs',
                                              container=container,
                                              tag_fallback=True))
                except exceptions.UnknownType:
                    util.DEBUG_LOG('Unkown hub item type({1}): {0}'.format(
                        elem, elem.attrib.get('type')))
コード例 #3
0
    def getLibrarySectionPrefs(self, uuid):
        # TODO: Make sure I did this right - ruuk
        librarySection = self.getLibrarySectionByUuid(uuid)

        if librarySection and librarySection.key:
            # Query and store the prefs only when asked for. We could just return the
            # items, but it'll be more useful to store the pref ids in an associative
            # array for ease of selecting the pref we need.

            if not librarySection.sectionPrefs:
                path = "/library/sections/{0}/prefs".format(librarySection.key)
                data = self.query(path)
                if data:
                    librarySection.sectionPrefs = {}
                    for elem in data:
                        item = plexobjects.buildItem(self, elem, path)
                        if item.id:
                            librarySection.sectionPrefs[item.id] = item

            return librarySection.sectionPrefs

        return None
コード例 #4
0
ファイル: plexresult.py プロジェクト: J0hnnyD03/Plex
    def addItem(self, container, node):
        if node.attrib.get('type') in ('track', 'movie', 'episode',
                                       'photo') and node.tag != 'PlayQueue':
            item = plexobjects.buildItem(self.server,
                                         node,
                                         self.address,
                                         container=self.container)
        else:
            item = plexobjects.PlexObject(node,
                                          server=self.container.server,
                                          container=self.container)

        # TODO(rob): handle channel settings. We should be able to utilize
        # the settings component with some modifications.
        if not item.isSettings():
            self.items.append(item)
        else:
            # Decrement the size and total size if applicable
            if self.container.get("size"):
                self.container.size = plexobjects.PlexValue(
                    str(self.container.size.asInt() - 1))
            if self.container.get("totalSize"):
                self.container.totalSize = plexobjects.PlexValue(
                    str(self.container.totalSize.asInt() - 1))
コード例 #5
0
 def getObject(self, key):
     data = self.query(key)
     return plexobjects.buildItem(self, data[0], key, container=self)