Homelabtoolkit v2
This commit is contained in:
@@ -129,6 +129,24 @@ async def list_collection_items(client, collection_id: str, user_id: str) -> lis
|
||||
return [normalize_item(raw) for raw in items]
|
||||
|
||||
|
||||
async def get_collection_item_count(client, collection_id: str) -> int:
|
||||
"""Ask Emby for the authoritative child count for one collection."""
|
||||
data = await client.get(
|
||||
"/Items",
|
||||
{
|
||||
"ParentId": collection_id,
|
||||
"Limit": "1",
|
||||
"Recursive": "false",
|
||||
},
|
||||
)
|
||||
if isinstance(data, dict):
|
||||
try:
|
||||
return int(data.get("TotalRecordCount", len(data.get("Items") or [])))
|
||||
except (TypeError, ValueError):
|
||||
return len(data.get("Items") or [])
|
||||
return len(data or [])
|
||||
|
||||
|
||||
async def add_collection_items(client, collection_id: str, item_ids: list[str]):
|
||||
"""Add items to a collection by id. No-op for an empty list."""
|
||||
if not item_ids:
|
||||
|
||||
Reference in New Issue
Block a user