Perform a GET request to the Tidal API with pagination resolution.
(
self,
url: str,
include: list[str] | str | None = None,
params: dict[str, Any] | None = None,
**kwargs,
)
| 196 | return a |
| 197 | |
| 198 | def get_paginated( |
| 199 | self, |
| 200 | url: str, |
| 201 | include: list[str] | str | None = None, |
| 202 | params: dict[str, Any] | None = None, |
| 203 | **kwargs, |
| 204 | ) -> Document[list[Any]]: |
| 205 | """ |
| 206 | Perform a GET request to the Tidal API with pagination resolution. |
| 207 | """ |
| 208 | include = include or [] |
| 209 | params = params or {} |
| 210 | |
| 211 | doc: Document[list[Any]] = { |
| 212 | "data": [], |
| 213 | "included": [], |
| 214 | "links": {"next": url}, |
| 215 | } |
| 216 | |
| 217 | while next_ := doc.get("links", {}).get("next"): |
| 218 | page_doc = self.get_json( |
| 219 | url=next_, params={**params, "include": include}, **kwargs |
| 220 | ) |
| 221 | doc = self.merge_multiresource_pagination(doc, page_doc) |
| 222 | |
| 223 | # Dedupe include |
| 224 | doc["included"] = list( |
| 225 | { |
| 226 | (item["type"], item["id"]): item |
| 227 | for item in doc.get("included", []) |
| 228 | }.values() |
| 229 | ) |
| 230 | return doc |
no test coverage detected