11from datetime import datetime
22from typing import Any , Optional
3+ from warnings import warn
34
45from requests import Response
56
@@ -112,6 +113,24 @@ def post_command(self, name: SonarrCommands, **kwargs) -> Any:
112113
113114 ## EPISODE
114115
116+ # GET /episode
117+ def get_episode (self , id_ : int , series : bool = False ) -> dict [str , Any ]:
118+ """Get get episodes by ID or series
119+
120+ Args:
121+ id_ (int): ID for Episode or Series.
122+ series (bool, optional): Set to true if the ID is for a Series. Defaults to false.
123+
124+ Returns:
125+ list[dict[str, Any]]: List of dictionaries with items
126+ """
127+ return self .assert_return (
128+ f"episode{ '' if series else f'/{ id_ } ' } " ,
129+ self .ver_uri ,
130+ dict ,
131+ params = {"seriesId" : id_ } if series else None ,
132+ )
133+
115134 # GET /episode
116135 def get_episodes_by_series_id (self , id_ : int ) -> list [dict [str , Any ]]:
117136 # sourcery skip: class-extract-method
@@ -123,11 +142,16 @@ def get_episodes_by_series_id(self, id_: int) -> list[dict[str, Any]]:
123142 Returns:
124143 list[dict[str, Any]]: List of dictionaries with items
125144 """
145+ warn (
146+ "This method is deprecated and will be removed in a future release. Please use get_episode()" ,
147+ DeprecationWarning ,
148+ stacklevel = 2 ,
149+ )
126150 params = {"seriesId" : id_ }
127151 return self .assert_return ("episode" , self .ver_uri , list , params )
128152
129153 # GET /episode/{id}
130- def get_episode_by_episode_id (self , id_ : int ) -> list [ dict [str , Any ] ]:
154+ def get_episode_by_episode_id (self , id_ : int ) -> dict [str , Any ]:
131155 """Gets a specific episode by database id
132156
133157 Args:
@@ -136,22 +160,30 @@ def get_episode_by_episode_id(self, id_: int) -> list[dict[str, Any]]:
136160 Returns:
137161 list[dict[str, Any]]: List of dictionaries with items
138162 """
139- return self .assert_return (f"episode/{ id_ } " , self .ver_uri , list )
163+ warn (
164+ "This method is deprecated and will be removed in a future release. Please use get_episode()" ,
165+ DeprecationWarning ,
166+ stacklevel = 2 ,
167+ )
168+ return self .assert_return (f"episode/{ id_ } " , self .ver_uri , dict )
140169
141170 # PUT /episode
142- def upd_episode (self , data : dict [str , Any ]) -> dict [str , Any ]:
143- """Update the given episodes, currently only monitored is changed, all other modifications are ignored.
144-
145- Note:
146- To be used in conjunction with get_episode()
171+ def upd_episode (self , id_ : int , data : dict [str , Any ]) -> dict [str , Any ]:
172+ """Update the given episodes, currently only monitored is supported
147173
148174 Args:
149- data (dict[str, Any]): All parameters to update episode
175+ id_ (int): ID of the Episode to be updated
176+ data (dict[str, Any]): Parameters to update the episode
177+
178+ Example:
179+ ::
180+ payload = {"monitored": True}
181+ sonarr.upd_episode(1, payload)
150182
151183 Returns:
152184 dict[str, Any]: Dictionary with updated record
153185 """
154- return self ._put ("episode" , self .ver_uri , data = data )
186+ return self ._put (f "episode/ { id_ } " , self .ver_uri , data = data )
155187
156188 ## EPISODE FILE
157189
@@ -261,37 +293,6 @@ def get_quality_profile(self, id_: Optional[int] = None) -> list[dict[str, Any]]
261293 path = f"profile/{ id_ } " if id_ else "profile"
262294 return self .assert_return (path , self .ver_uri , list )
263295
264- # PUT /profile/{id}
265- # TODO: this doesnt work on v3 API
266- def upd_quality_profile (self , id_ : int , data : dict [str , Any ]) -> dict [str , Any ]:
267- """Update the quality profile data.
268-
269- Note:
270- To be used in conjunction with get_quality_profile()
271-
272- Args:
273- id_ (int): Profile ID to Update
274- data (dict[str, Any]): All parameters to update
275-
276- Returns:
277- dict[str, Any]: Dictionary with updated record
278- """
279- return self ._put (f"profile/{ id_ } " , self .ver_uri , data = data )
280-
281- # DELETE /profile
282- # TODO: this doesnt work on v3 API
283- def del_quality_profile (self , id_ : int ) -> Response :
284- """Removes a specific quality profile from the blocklist
285-
286- Args:
287- id_ (int): Quality profile id from database
288-
289- Returns:
290- Response: HTTP Response
291- """
292- params = {"id" : id_ }
293- return self ._delete ("profile" , self .ver_uri , params = params )
294-
295296 ## QUEUE
296297
297298 # GET /queue
0 commit comments