1
1
from datetime import datetime
2
2
from typing import Any , Optional
3
+ from warnings import warn
3
4
4
5
from requests import Response
5
6
@@ -112,6 +113,24 @@ def post_command(self, name: SonarrCommands, **kwargs) -> Any:
112
113
113
114
## EPISODE
114
115
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
+
115
134
# GET /episode
116
135
def get_episodes_by_series_id (self , id_ : int ) -> list [dict [str , Any ]]:
117
136
# sourcery skip: class-extract-method
@@ -123,11 +142,16 @@ def get_episodes_by_series_id(self, id_: int) -> list[dict[str, Any]]:
123
142
Returns:
124
143
list[dict[str, Any]]: List of dictionaries with items
125
144
"""
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
+ )
126
150
params = {"seriesId" : id_ }
127
151
return self .assert_return ("episode" , self .ver_uri , list , params )
128
152
129
153
# 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 ]:
131
155
"""Gets a specific episode by database id
132
156
133
157
Args:
@@ -136,22 +160,30 @@ def get_episode_by_episode_id(self, id_: int) -> list[dict[str, Any]]:
136
160
Returns:
137
161
list[dict[str, Any]]: List of dictionaries with items
138
162
"""
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 )
140
169
141
170
# 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
147
173
148
174
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)
150
182
151
183
Returns:
152
184
dict[str, Any]: Dictionary with updated record
153
185
"""
154
- return self ._put ("episode" , self .ver_uri , data = data )
186
+ return self ._put (f "episode/ { id_ } " , self .ver_uri , data = data )
155
187
156
188
## EPISODE FILE
157
189
@@ -261,37 +293,6 @@ def get_quality_profile(self, id_: Optional[int] = None) -> list[dict[str, Any]]
261
293
path = f"profile/{ id_ } " if id_ else "profile"
262
294
return self .assert_return (path , self .ver_uri , list )
263
295
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
-
295
296
## QUEUE
296
297
297
298
# GET /queue
0 commit comments