Skip to content

Commit

Permalink
Fix get_all_bouquets to retrieve all bouquets
Browse files Browse the repository at this point in the history
  • Loading branch information
autinerd committed Jan 5, 2025
1 parent 6946269 commit 819267b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 65 deletions.
12 changes: 8 additions & 4 deletions openwebif/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
if TYPE_CHECKING:
from collections.abc import Mapping

from openwebif.types import Bouquets

_LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -508,15 +510,17 @@ async def get_all_services(self) -> dict[str, Any]:
"""Get list of all services."""
return await self._call_api(PATH_GETALLSERVICES)

async def get_bouquets(self, stype: SType = SType.TV) -> dict[str, Any]:
async def get_bouquets(self, stype: SType = SType.TV) -> Bouquets:
"""Get list of bouquets."""
return await self._call_api(PATH_BOUQUETS, {"stype": str(stype)})

async def get_all_bouquets(self) -> dict[str, Any]:
async def get_all_bouquets(self) -> Bouquets:
"""Get list of all tv and radio bouquets."""
return {
**(await self.get_bouquets(SType.TV)),
**(await self.get_bouquets(SType.RADIO)),
"bouquets": [
*((await self.get_bouquets(SType.TV))["bouquets"]),
*((await self.get_bouquets(SType.RADIO))["bouquets"]),
],
}

async def zap(self, source: str) -> bool:
Expand Down
9 changes: 9 additions & 0 deletions openwebif/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Types for openwebif."""

from typing import TypedDict


class Bouquets(TypedDict):
"""The bouquets type."""

bouquets: list[list[str]]
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ ignore = [
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`

"COM812",
"ISC001"
]

[tool.ruff.lint.extend-per-file-ignores]
Expand Down
Loading

0 comments on commit 819267b

Please sign in to comment.