コード例 #1
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def jumpList(self, filter_=None, sort=None, unwatched=False, type_=None):
        if self.key.startswith('/'):
            path = '{0}/firstCharacter'.format(self.key)
        else:
            path = '/library/sections/{0}/firstCharacter'.format(self.key)

        args = {}

        if filter_:
            args[filter_[0]] = filter_[1]

        if sort:
            args['sort'] = '{0}:{1}'.format(*sort)

        if type_:
            args['type'] = str(type_)

        if unwatched:
            args[self.TYPE == 'movie' and 'unwatched' or 'unwatchedLeaves'] = 1

        if args:
            path += util.joinArgs(args)

        try:
            return plexobjects.listItems(self.server, path, bytag=True)
        except exceptions.BadRequest:
            util.ERROR('jumpList() request error for path: {0}'.format(
                repr(path)))
            return None
コード例 #2
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def all(self,
            start=None,
            size=None,
            filter_=None,
            sort=None,
            unwatched=False,
            type_=None):
        if self.key.startswith('/'):
            path = '{0}/all'.format(self.key)
        else:
            path = '/library/sections/{0}/all'.format(self.key)

        args = {}

        if size is not None:
            args['X-Plex-Container-Start'] = start
            args['X-Plex-Container-Size'] = size

        if filter_:
            args[filter_[0]] = filter_[1]

        if sort:
            args['sort'] = '{0}:{1}'.format(*sort)

        if type_:
            args['type'] = str(type_)

        if unwatched:
            args[self.TYPE == 'movie' and 'unwatched' or 'unwatchedLeaves'] = 1

        if args:
            path += util.joinArgs(args)

        return plexobjects.listItems(self.server, path)
コード例 #3
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def items(self):
        if not self._itemsLoaded:
            path = '/playlists/{0}/items'.format(self.ratingKey)
            self._items = plexobjects.listItems(self.server, path)
            self._itemsLoaded = True

        return playlist.BasePlaylist.items(self)
コード例 #4
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def extend(self, start=None, size=None):
        path = '/playlists/all?playlistType={0}'.format(self.type)

        args = {}

        if size is not None:
            args['X-Plex-Container-Start'] = start
            args['X-Plex-Container-Size'] = size
        else:
            start = 0

        if args:
            path += '&' + util.joinArgs(args).lstrip('?')

        items = plexobjects.listItems(self.server, path)

        if not items:
            return

        self.set('offset', start)
        self.set('size', len(items))
        self.set('more', (items[0].container.offset.asInt() +
                          items[0].container.size.asInt() <
                          items[0].container.totalSize.asInt()) and '1' or '')
        return items
コード例 #5
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def search(self,
            title=None,
            sort=None,
            maxresults=999999,
            libtype=None,
            **kwargs):
     """ Search the library. If there are many results, they will be fetched from the server
         in batches of X_PLEX_CONTAINER_SIZE amounts. If you're only looking for the first <num>
         results, it would be wise to set the maxresults option to that amount so this functions
         doesn't iterate over all results on the server.
         title: General string query to search for.
         sort: column:dir; column can be any of {addedAt, originallyAvailableAt, lastViewedAt,
           titleSort, rating, mediaHeight, duration}. dir can be asc or desc.
         maxresults: Only return the specified number of results
         libtype: Filter results to a spcifiec libtype {movie, show, episode, artist, album, track}
         kwargs: Any of the available filters for the current library section. Partial string
           matches allowed. Multiple matches OR together. All inputs will be compared with the
           available options and a warning logged if the option does not appear valid.
             'unwatched': Display or hide unwatched content (True, False). [all]
             'duplicate': Display or hide duplicate items (True, False). [movie]
             'actor': List of actors to search ([actor_or_id, ...]). [movie]
             'collection': List of collections to search within ([collection_or_id, ...]). [all]
             'contentRating': List of content ratings to search within ([rating_or_key, ...]). [movie, tv]
             'country': List of countries to search within ([country_or_key, ...]). [movie, music]
             'decade': List of decades to search within ([yyy0, ...]). [movie]
             'director': List of directors to search ([director_or_id, ...]). [movie]
             'genre': List Genres to search within ([genere_or_id, ...]). [all]
             'network': List of TV networks to search within ([resolution_or_key, ...]). [tv]
             'resolution': List of video resolutions to search within ([resolution_or_key, ...]). [movie]
             'studio': List of studios to search within ([studio_or_key, ...]). [music]
             'year': List of years to search within ([yyyy, ...]). [all]
     """
     # Cleanup the core arguments
     args = {}
     for category, value in kwargs.items():
         args[category] = self._cleanSearchFilter(category, value, libtype)
     if title is not None:
         args['title'] = title
     if sort is not None:
         args['sort'] = self._cleanSearchSort(sort)
     if libtype is not None:
         args['type'] = plexobjects.searchType(libtype)
     # Iterate over the results
     results, subresults = [], '_init'
     args['X-Plex-Container-Start'] = 0
     args['X-Plex-Container-Size'] = min(util.X_PLEX_CONTAINER_SIZE,
                                         maxresults)
     while subresults and maxresults > len(results):
         query = '/library/sections/%s/all%s' % (self.key,
                                                 util.joinArgs(args))
         subresults = plexobjects.listItems(self.server, query)
         results += subresults[:maxresults - len(results)]
         args['X-Plex-Container-Start'] += args['X-Plex-Container-Size']
     return results
コード例 #6
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def search(self, title, libtype=None, **kwargs):
     """ Searching within a library section is much more powerful. It seems certain attributes on the media
         objects can be targeted to filter this search down a bit, but I havent found the documentation for
         it. For example: "studio=Comedy%20Central" or "year=1999" "title=Kung Fu" all work. Other items
         such as actor=<id> seem to work, but require you already know the id of the actor.
         TLDR: This is untested but seems to work. Use library section search when you can.
     """
     args = {}
     if title:
         args['title'] = title
     if libtype:
         args['type'] = plexobjects.searchType(libtype)
     for attr, value in kwargs.items():
         args[attr] = value
     query = '/library/all%s' % util.joinArgs(args)
     return plexobjects.listItems(self.server, query)
コード例 #7
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def listChoices(self, category, libtype=None, **kwargs):
        """ List choices for the specified filter category. kwargs can be any of the same
            kwargs in self.search() to help narrow down the choices to only those that
            matter in your current context.
        """
        if category in kwargs:
            raise exceptions.BadRequest(
                'Cannot include kwarg equal to specified category: %s' %
                category)
        args = {}
        for subcategory, value in kwargs.items():
            args[category] = self._cleanSearchFilter(subcategory, value)
        if libtype is not None:
            args['type'] = plexobjects.searchType(libtype)
        query = '/library/sections/%s/%s%s' % (self.key, category,
                                               util.joinArgs(args))

        return plexobjects.listItems(self.server, query, bytag=True)
コード例 #8
0
ファイル: http.py プロジェクト: 89mclarenstang/plex-for-kodi
    def __init__(self, response, path, server=None):
        self.event = response
        if self.event:
            self.event.content  # force data to be read
            self.event.close()

        data = self.getBodyXml()

        plexobjects.PlexContainer.__init__(self,
                                           data,
                                           initpath=path,
                                           server=server,
                                           address=path)
        self.container = self

        self.items = plexobjects.listItems(server,
                                           path,
                                           data=data,
                                           container=self)
コード例 #9
0
    def jumpList(self, filter_=None, sort=None, unwatched=False):
        if self.key.startswith('/'):
            path = '{0}/firstCharacter'.format(self.key)
        else:
            path = '/library/sections/{0}/firstCharacter'.format(self.key)

        args = {}

        if filter_:
            args[filter_[0]] = filter_[1]

        if sort:
            args['sort'] = '{0}:{1}'.format(*sort)

        if unwatched:
            args[self.TYPE == 'movie' and 'unwatched' or 'unwatchedLeaves'] = 1

        if args:
            path += util.joinArgs(args)

        return plexobjects.listItems(self.server, path, bytag=True)
コード例 #10
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def extend(self, start=None, size=None):
        path = self.key

        args = {}

        if size is not None:
            args['X-Plex-Container-Start'] = start
            args['X-Plex-Container-Size'] = size

        if args:
            path += util.joinArgs(
                args
            ) if '?' not in path else '&' + util.joinArgs(args).lstrip('?')

        items = plexobjects.listItems(self.server, path)
        self.offset = plexobjects.PlexValue(start)
        self.size = plexobjects.PlexValue(len(items))
        self.more = plexobjects.PlexValue(
            (items[0].container.offset.asInt() +
             items[0].container.size.asInt() <
             items[0].container.totalSize.asInt()) and '1' or '')
        return items
コード例 #11
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
    def extend(self, start=0, size=0):
        if not self._items:
            self._items = [None] * self.leafCount.asInt()

        args = {}

        if size is not None:
            args['X-Plex-Container-Start'] = start
            args['X-Plex-Container-Size'] = size

        path = '/playlists/{0}/items'.format(self.ratingKey)
        if args:
            path += util.joinArgs(
                args
            ) if '?' not in path else '&' + util.joinArgs(args).lstrip('?')

        items = plexobjects.listItems(self.server, path)
        self._items[start:start + len(items)] = items

        self.trigger('items.added')

        return items
コード例 #12
0
ファイル: audio.py プロジェクト: J0hnnyD03/Plex
 def artist(self):
     return plexobjects.listItems(self.server, self.grandparentKey)[0]
コード例 #13
0
ファイル: audio.py プロジェクト: J0hnnyD03/Plex
 def album(self):
     return plexobjects.listItems(self.server, self.parentKey)[0]
コード例 #14
0
 def all(self):
     path = self.key
     return plexobjects.listItems(self.server, path)
コード例 #15
0
 def show(self):
     if not self._show:
         self._show = plexobjects.listItems(self.server,
                                            self.grandparentKey)[0]
     return self._show
コード例 #16
0
 def season(self):
     if not self._season:
         self._season = plexobjects.listItems(self.server,
                                              self.parentKey)[0]
     return self._season
コード例 #17
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def recentlyAdded(self):
     return plexobjects.listItems(self.server, '/library/recentlyAdded')
コード例 #18
0
ファイル: audio.py プロジェクト: J0hnnyD03/Plex
 def tracks(self, watched=None):
     path = '%s/children' % self.key
     return plexobjects.listItems(self.server, path, watched=watched)
コード例 #19
0
 def seasons(self):
     path = self.key
     return plexobjects.listItems(self.server, path, Season.TYPE)
コード例 #20
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def randomArts(self):
     return plexobjects.listItems(
         self.server,
         '/library/arts?sort=random&type=1%2c2%2c8&X-Plex-Container-Start=0&X-Plex-Container-Size=50'
     )
コード例 #21
0
 def playlists(self, start=0, size=10, hub=None):
     try:
         return plexobjects.listItems(self, '/playlists/all')
     except exceptions.BadRequest:
         return None
コード例 #22
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def onDeck(self):
     return plexobjects.listItems(self.server,
                                  '/library/sections/%s/onDeck' % self.key)
コード例 #23
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def all(self):
     return plexobjects.listItems(self.server, '/library/all')
コード例 #24
0
ファイル: audio.py プロジェクト: J0hnnyD03/Plex
 def albums(self):
     path = '%s/children' % self.key
     return plexobjects.listItems(self.server, path, Album.TYPE)
コード例 #25
0
ファイル: audio.py プロジェクト: J0hnnyD03/Plex
 def tracks(self, watched=None):
     leavesKey = '/library/metadata/%s/allLeaves' % self.ratingKey
     return plexobjects.listItems(self.server, leavesKey, watched=watched)
コード例 #26
0
 def sectionOnDeck(self):
     query = '/library/sections/{0}/onDeck'.format(
         self.getLibrarySectionId())
     return plexobjects.listItems(self.server, query)
コード例 #27
0
 def episodes(self, watched=None):
     path = self.key
     return plexobjects.listItems(self.server, path, watched=watched)
コード例 #28
0
ファイル: plexlibrary.py プロジェクト: Zero0Q/plex-for-kodi
 def onDeck(self):
     return plexobjects.listItems(self.server, '/library/onDeck')