Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 145 add language endpoint #147

Merged
merged 2 commits into from
Apr 17, 2023
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
21 changes: 21 additions & 0 deletions pyarr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,24 @@ def get_command(self, id_: Optional[int] = None) -> Union[JsonArray, JsonObject]
"""
path = f"command{f'/{id_}' if id_ else ''}"
return self._get(path, self.ver_uri)

# GET /language/{id}
# TODO: update notes and tests for Sonarr once resolved
def get_language(
self, id_: Optional[int] = None
) -> Union[JsonArray, dict[Any, Any]]:
"""Gets all language profiles or specific one with id

Note:
This method is not working in Sonarr, use get_language_profile()
I have raised this with the Sonarr team.

Args:
id_ (Optional[int], optional): Language profile id from database. Defaults to None.

Returns:
Union[JsonArray, dict[Any, Any]]: List of dictionaries with items
"""

path = f"language{f'/{id_}' if id_ else ''}"
return self._get(path, self.ver_uri)
40 changes: 9 additions & 31 deletions pyarr/sonarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,44 +645,22 @@ def get_language_profile(
Args:
id_ (Optional[int], optional): Language profile id from database. Defaults to None.

Note:
This method is deprecated and will be removed in a
future release. Please use get_language()

Returns:
Union[JsonArray, dict[Any, Any]]: List of dictionaries with items
"""
warn(
"This method is deprecated and will be removed in a future release. Please use get_language()",
DeprecationWarning,
stacklevel=2,
)

path = f"languageprofile{f'/{id_}' if id_ else ''}"
return self._get(path, self.ver_uri)

# PUT /languageprofile/{id}
def upd_language_profile(self, id_: int, data: JsonObject) -> JsonObject:
"""Update the language profile data

Note:
To be used in conjunction with get_language_profile()

Args:
id_ (int): Profile ID to Update
data (JsonObject): All parameters to update

Returns:
JsonObject: Dictionary of updated record
"""

return self._put(f"languageprofile/{id_}", self.ver_uri, data=data)

# DELETE /languageprofile
def del_language_profile(
self, id_: int
) -> Union[Response, JsonObject, dict[Any, Any]]:
"""Removes a specific language profile from the blocklist

Args:
id_ (int): Profile ID from database

Returns:
Response: HTTP Response
"""
return self._delete(f"languageprofile/{id_}", self.ver_uri)

# GET /languageprofile/schema/{id}
def get_language_profile_schema(
self, id_: Optional[int] = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyarr"
version = "5.0.1"
version = "5.1.0"
description = "Synchronous Sonarr, Radarr, Lidarr and Readarr API's for Python"
authors = ["Steven Marks <[email protected]>"]
license = "MIT"
Expand Down
8 changes: 8 additions & 0 deletions tests/test_lidarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ def test_upd_metadata_provider(lidarr_client: LidarrAPI):
assert isinstance(data, dict)


def test_get_language(lidarr_client: LidarrAPI):
data = lidarr_client.get_language()
assert isinstance(data, list)

data = lidarr_client.get_language(data[0]["id"])
assert isinstance(data, dict)


@pytest.mark.usefixtures
@responses.activate
def test_get_queue(lidarr_mock_client: LidarrAPI):
Expand Down
Loading