MCPcopy Index your code
hub / github.com/beetbox/beets / get_paginated

Method get_paginated

beetsplug/tidal/api.py:198–230  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 2

get_tracksMethod · 0.95
get_albumsMethod · 0.95

Calls 3

getMethod · 0.45
get_jsonMethod · 0.45

Tested by

no test coverage detected