Skip to content

Commit

Permalink
Merge pull request #113 from totaldebug/111-type_hint_errors
Browse files Browse the repository at this point in the history
fix: assertion issue with get_movie
  • Loading branch information
marksie1988 committed Jun 28, 2022
2 parents 60706fc + 2817c5c commit b683c9c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
30 changes: 23 additions & 7 deletions pyarr/radarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ def get_movie(
Returns:
Union[list[dict[str, Any]], dict[str, Any]]: List or Dictionary with items
"""

return self.assert_return(
f"movie{'' if id_ is None or tmdb else f'/{id_}'}",
self.ver_uri,
list if id_ is None else dict,
list if not id_ or tmdb else dict,
params=None if id_ is None else {"tmdbid": id_},
)

Expand Down Expand Up @@ -163,6 +162,10 @@ def get_movie_by_movie_id(self, id_: int) -> dict[str, Any]:
Args:
id_ (int): Database Id of movie to return
Note:
This method is deprecated and will be removed in a
future release. Please use get_movie()
Returns:
list[dict[str, Any]]: List of dictionaries with items
"""
Expand All @@ -175,20 +178,33 @@ def get_movie_by_movie_id(self, id_: int) -> dict[str, Any]:

# DELETE /movie/{id}
def del_movie(
self, id_: int, delete_files: bool = False, add_exclusion: bool = False
self,
id_: Union[int, list],
delete_files: bool = False,
add_exclusion: bool = False,
) -> Union[Response, dict[str, Any], dict[Any, Any]]:
"""Delete a single movie by database id.
"""Delete a single movie or multiple movies by database id.
Args:
id_ (int): Database Id of movie to delete.
id_ (Union[int, list]): Int with single movie Id or list with multiple IDs to delete.
delete_files (bool, optional): Delete movie files when deleting movies. Defaults to False.
add_exclusion (bool, optional): Add deleted movies to List Exclusions. Defaults to False.
Returns:
Response: HTTP Response
"""
params = {"deleteFiles": delete_files, "addExclusion": add_exclusion}
return self._delete(f"movie/{id_}", self.ver_uri, params=params)
params: dict[str, str | list[int]] = {
"deleteFiles": str(delete_files),
"addImportExclusion": str(add_exclusion),
}
if isinstance(id_, list):
params["moviIds"] = id_
return self._delete(
"movie/editor" if isinstance(id_, list) else f"movie/{id_}",
self.ver_uri,
params=None if isinstance(id_, list) else params,
data=params if isinstance(id_, list) else None,
)

# GET /movie/lookup
def lookup_movie(self, term: str) -> list[dict[str, Any]]:
Expand Down
8 changes: 8 additions & 0 deletions pyarr/sonarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ def get_episodes_by_series_id(self, id_: int) -> list[dict[str, Any]]:
Args:
id_ (int): Database id for series
Note:
This method is deprecated and will be removed in a
future release. Please use get_episode()
Returns:
list[dict[str, Any]]: List of dictionaries with items
"""
Expand All @@ -157,6 +161,10 @@ def get_episode_by_episode_id(self, id_: int) -> dict[str, Any]:
Args:
id_ (int): Database id for episode
Note:
This method is deprecated and will be removed in a
future release. Please use get_episode()
Returns:
list[dict[str, Any]]: List of dictionaries with items
"""
Expand Down

0 comments on commit b683c9c

Please sign in to comment.