Exemplo n.º 1
0
    def postPlay(self, **params):
        query = '/hubs/metadata/{0}/postplay'.format(self.ratingKey)
        data = self.server.query(query, params=params)
        container = plexobjects.PlexContainer(data,
                                              initpath=query,
                                              server=self.server,
                                              address=query)

        hubs = {}
        for elem in data:
            hub = plexlibrary.Hub(elem,
                                  server=self.server,
                                  container=container)
            hubs[hub.hubIdentifier] = hub
        return hubs
Exemplo n.º 2
0
    def parseFakeXMLResponse(self, data):
        if self.parsed:
            return self.parsed

        self.parsed = False

        if data is not None:
            self.container = plexobjects.PlexContainer(data,
                                                       initpath=self.address,
                                                       server=self.server,
                                                       address=self.address)

            for node in data:
                self.addItem(self.container, node)

            self.parsed = True

        return self.parsed
Exemplo n.º 3
0
    def hubs(self, section=None, count=None, search_query=None):
        hubs = []

        params = {}
        if search_query:
            q = '/hubs/search'
            params['query'] = search_query.lower()
            if section:
                params['sectionId'] = section

            if count is not None:
                params['limit'] = count
        else:
            q = '/hubs'
            if section:
                if section == 'playlists':
                    audio = plexlibrary.AudioPlaylistHub(False,
                                                         server=self.server)
                    video = plexlibrary.VideoPlaylistHub(False,
                                                         server=self.server)
                    if audio.items:
                        hubs.append(audio)
                    if video.items:
                        hubs.append(video)
                    return hubs
                else:
                    q = '/hubs/sections/%s' % section

            if count is not None:
                params['count'] = count

        data = self.query(q, params=params)
        container = plexobjects.PlexContainer(data,
                                              initpath=q,
                                              server=self,
                                              address=q)

        for elem in data:
            hubs.append(plexlibrary.Hub(elem, server=self,
                                        container=container))
        return hubs
Exemplo n.º 4
0
    def parseResponse(self):
        if self.parsed:
            return self.parsed

        self.parsed = False

        if self.isSuccess():
            data = self.getBodyXml()
            if data is not None:
                self.container = plexobjects.PlexContainer(
                    data,
                    initpath=self.address,
                    server=self.server,
                    address=self.address)

                for node in data:
                    self.addItem(self.container, node)

                self.parsed = True

        return self.parsed
Exemplo n.º 5
0
    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')))