Skip to content

Commit

Permalink
Merge pull request #147 from marksie1988/145-add-language-endpoint
Browse files Browse the repository at this point in the history
145 add language endpoint
  • Loading branch information
marksie1988 authored Apr 17, 2023
2 parents 4ff6086 + e4db8ea commit bfa1f36
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 107 deletions.
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

0 comments on commit bfa1f36

Please sign in to comment.