giphypop.py
def trending(self, rating=None, limit=DEFAULT_SEARCH_LIMIT):
        """
        Retrieve GIFs currently trending online. The data returned mirrors
        that used to create The Hot 100 list of GIFs on Giphy.

        :param rating: limit results to those rated (y,g, pg, pg-13 or r).
        :type rating: string
        :param limit: Maximum number of results to yield
        :type limit: int
        """

        results_yielded = 0  # Count how many things we yield
        page, per_page = 0, 25
        params = {'rating': rating} if rating else {}
        fetch = partial(self._fetch, 'trending', **params)

        # Generate results until we 1) run out of pages 2) reach a limit
        while True:
            data = fetch(offset=page, limit=per_page)
            page += per_page

            # Guard for empty results
            if not data['data']:
                raise StopIteration

            for item in data['data']:
                results_yielded += 1
                yield GiphyImage(item)

                if limit is not None and results_yielded >= limit:
                    raise StopIteration

            # Check yieled limit and whether or not there are more items
            if (page >= data['pagination']['total_count'] or
                    (limit is not None and results_yielded >= limit)):
                raise StopIteration
def trending(self, rating=None, limit=DEFAULT_SEARCH_LIMIT):
        results_yielded = 0  # Count how many things we yield
        page, per_page = 0, 25
        params = {'rating': rating} if rating else {}
        fetch = partial(self._fetch, 'trending', **params)

        # Generate results until we 1) run out of pages 2) reach a limit
        while True:
            data = fetch(offset=page, limit=per_page)
            page += per_page

            # Guard for empty results
            if not data['data']:
                raise StopIteration

            for item in data['data']:
                results_yielded += 1
                yield GiphyImage(item)

                if limit is not None and results_yielded >= limit:
                    raise StopIteration

            # Check yieled limit and whether or not there are more items
            if (page >= data['pagination']['total_count'] or
                    (limit is not None and results_yielded >= limit)):
                raise StopIteration
def trending ( self , rating = None , limit = DEFAULT_SEARCH_LIMIT ) : results_yielded = 0 # Count how many things we yield page , per_page = 0 , 25 params = { 'rating' : rating } if rating else { } fetch = partial ( self . _fetch , 'trending' , * * params ) # Generate results until we 1) run out of pages 2) reach a limit while True : data = fetch ( offset = page , limit = per_page ) page += per_page # Guard for empty results if not data [ 'data' ] : raise StopIteration for item in data [ 'data' ] : results_yielded += 1 yield GiphyImage ( item ) if limit is not None and results_yielded >= limit : raise StopIteration # Check yieled limit and whether or not there are more items if ( page >= data [ 'pagination' ] [ 'total_count' ] or ( limit is not None and results_yielded >= limit ) ) : raise StopIteration
Retrieve GIFs currently trending online. The data returned mirrors
        that used to create The Hot 100 list of GIFs on Giphy.

        :param rating: limit results to those rated (y,g, pg, pg-13 or r).
        :type rating: string
        :param limit: Maximum number of results to yield
        :type limit: int
Retrieve GIFs currently trending online . The data returned mirrors that used to create The Hot 100 list of GIFs on Giphy .