Discover Sonarr episode downloads and keep live tracker updating
Magent CI/CD / verify (push) Canceled after 1m9s
Magent CI/CD / deploy-prod (push) Canceled after 0s
Magent CI/CD / deploy-beta (push) Canceled after 0s

This commit is contained in:
2026-09-06 22:46:01 +12:00
parent bd668715a3
commit 625f9ad7f0
7 changed files with 157 additions and 10 deletions
+16 -1
View File
@@ -33,7 +33,22 @@ class SonarrClient(ApiClient):
return await self.get("/api/v3/qualityprofile")
async def get_queue(self, series_id: int) -> Optional[Dict[str, Any]]:
return await self.get("/api/v3/queue", params={"seriesId": series_id})
records = []
page = 1
while True:
result = await self.get("/api/v3/queue", params={
"seriesIds": series_id, "includeEpisode": "true",
"page": page, "pageSize": 100,
})
if not isinstance(result, dict) or not isinstance(result.get("records"), list):
raise ValueError("Sonarr returned an invalid queue")
batch = result["records"]
records.extend(batch)
if not batch or len(records) >= int(result.get("totalRecords", len(records))):
return {**result, "records": records, "totalRecords": len(records)}
page += 1
if page > 100:
raise ValueError("Sonarr queue exceeded the safe paging limit")
async def get_indexers(self) -> Optional[Dict[str, Any]]:
return await self.get("/api/v3/indexer")