Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pylint = "3.0.3"
pytest = "7.4.4"
pytest-asyncio = "0.23.4"
pytest-cov = "4.1.0"
ruff = "0.1.14"
ruff = "0.1.15"
safety = "3.0.1"
syrupy = "4.6.0"
types-cachetools = "5.3.0.7"
Expand Down
3 changes: 3 additions & 0 deletions src/radios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def country(self) -> str | None:
Returns
-------
Country name or None if no country code is set.

"""
if resolved_country := pycountry.countries.get(alpha_2=self.country_code):
return cast(str, resolved_country.name)
Expand All @@ -123,6 +124,7 @@ def favicon(self) -> str:
Returns
-------
URL to the favicon.

"""
return f"https://flagcdn.com/256x192/{self.code.lower()}.png"

Expand All @@ -142,6 +144,7 @@ def favicon(self) -> str | None:
Returns
-------
URL to the favicon.

"""
if self.code:
return f"https://flagcdn.com/256x192/{self.code.lower()}.png"
Expand Down
11 changes: 11 additions & 0 deletions src/radios/radio_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async def _request(
with the Radio Browser API.
RadioBrowserError: Received an unexpected response from the
Radio Browser API.

"""
if self._host is None:
resolver = DNSResolver()
Expand Down Expand Up @@ -119,6 +120,7 @@ async def stats(self) -> Stats:
Returns
-------
A Stats object, with information about the Radio Browser API.

"""
response = await self._request("stats")
return Stats.from_json(response)
Expand All @@ -134,6 +136,7 @@ async def station_click(self, *, uuid: str) -> None:
Args:
----
uuid: UUID of the station.

"""
await self._request(f"url/{uuid}")

Expand All @@ -160,6 +163,7 @@ async def countries( # noqa: PLR0913
Returns:
-------
A Stats object, with information about the Radio Browser API.

"""
countries_data = await self._request(
"countrycodes",
Expand Down Expand Up @@ -210,6 +214,7 @@ async def languages( # noqa: PLR0913
Returns:
-------
A list of Language objects.

"""
languages_data = await self._request(
"languages",
Expand Down Expand Up @@ -273,6 +278,7 @@ async def search( # noqa: PLR0913
Returns:
-------
A list of Station objects.

"""
uri = "stations/search"
if filter_by is not None:
Expand Down Expand Up @@ -312,6 +318,7 @@ async def station(self, *, uuid: str) -> Station | None:
Returns:
-------
A Station object if found.

"""
stations = await self.stations(
filter_by=FilterBy.UUID,
Expand Down Expand Up @@ -349,6 +356,7 @@ async def stations( # noqa: PLR0913
Returns:
-------
A list of Station objects.

"""
uri = "stations"
if filter_by is not None:
Expand Down Expand Up @@ -392,6 +400,7 @@ async def tags( # noqa: PLR0913
Returns:
-------
A list of Tags objects.

"""
tags_data = await self._request(
"tags",
Expand All @@ -417,6 +426,7 @@ async def __aenter__(self) -> Self:
Returns
-------
The RadioBrowser object.

"""
return self

Expand All @@ -426,5 +436,6 @@ async def __aexit__(self, *_exc_info: object) -> None:
Args:
----
_exc_info: Exec type.

"""
await self.close()