Utility: Pagination and Blurhash¶
These functions allow for convenient retrieval of paginated data.
Fetches the next page of results of a paginated request. Pass in the previous page in its entirety, or the pagination information dict returned as a part of that pages last status (‘_pagination_next’).
Returns the next page or None if no further data is available.
Fetches the previous page of results of a paginated request. Pass in the previous page in its entirety, or the pagination information dict returned as a part of that pages first status (‘_pagination_prev’).
Returns the previous page or None if no further data is available.
Fetches all the remaining pages of a paginated request starting from a first page and returns the entire set of results (including the first page that was passed in) as a big list.
Be careful, as this might generate a lot of requests, depending on what you are fetching, and might cause you to run into rate limits very quickly.
This function allows for easy basic decoding of blurhash strings to images. This requires Mastodon.pys optional “blurhash” feature dependencies.
decode_blurhash(media_dict, out_size=(16, 16), size_per_component=True, return_linear=True)¶
Basic media-dict blurhash decoding.
out_size is the desired result size in pixels, either absolute or per blurhash component (this is the default).
By default, this function will return the image as linear RGB, ready for further scaling operations. If you want to display the image directly, set return_linear to False.
Returns the decoded blurhash image as a three-dimensional list: [height][width], with the last dimension being RGB colours.
For further info and tips for advanced usage, refer to the documentation for the blurhash module: https://github.com/halcy/blurhash-python