Skip to content

Commit 49c650c

Browse files
committed
add helper methods
1 parent 84c06ae commit 49c650c

File tree

4 files changed

+225
-7
lines changed

4 files changed

+225
-7
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.3
1+
1.2.4

arrapi/apis/radarr.py

+105-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,111 @@ def search_movies(self, term: str) -> List[Movie]:
123123
"""
124124
return [Movie(self, data=d) for d in self._raw.get_movie_lookup(term)]
125125

126-
def add_multiple_movies(self, ids: List[Union[int, str, Movie]],
126+
def add_movie(
127+
self,
128+
root_folder: Union[str, int, "RootFolder"],
129+
quality_profile: Union[str, int, "QualityProfile"],
130+
movie_id: Optional[int] = None,
131+
tmdb_id: Optional[int] = None,
132+
imdb_id: Optional[str] = None,
133+
monitor: bool = True,
134+
search: bool = True,
135+
minimum_availability: str = "announced",
136+
tags: Optional[List[Union[str, int, Tag]]] = None
137+
) -> Movie:
138+
""" Gets a :class:`~arrapi.objs.reload.Movie` by one of the IDs and adds it to Radarr.
139+
140+
Parameters:
141+
root_folder (Union[str, int, RootFolder]): Root Folder for the Movie.
142+
quality_profile (Union[str, int, QualityProfile]): Quality Profile for the Movie.
143+
movie_id (Optional[int]): Search by Radarr Movie ID.
144+
tmdb_id (Optional[int]): Search by TMDb ID.
145+
imdb_id (Optional[int]): Search by IMDb ID.
146+
monitor (bool): Monitor the Movie.
147+
search (bool): Search for the Movie after adding.
148+
minimum_availability (str): Minimum Availability for the Movie. Valid options are announced, inCinemas, released, or preDB.
149+
tags (Optional[List[Union[str, int, Tag]]]): Tags to be added to the Movie.
150+
151+
Returns:
152+
:class:`~arrapi.objs.reload.Movie`: Movie for the ID given.
153+
154+
Raises:
155+
:class:`ValueError`: When no ID is given.
156+
:class:`~arrapi.exceptions.NotFound`: When there's no movie with that ID.
157+
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
158+
:class:`~arrapi.exceptions.Exists`: When the Movie already Exists in Radarr.
159+
"""
160+
movie = self.get_movie(movie_id=movie_id, tmdb_id=tmdb_id, imdb_id=imdb_id)
161+
movie.add(root_folder, quality_profile, monitor=monitor, search=search,
162+
minimum_availability=minimum_availability, tags=tags)
163+
return movie
164+
165+
def edit_movie(
166+
self,
167+
movie_id: Optional[int] = None,
168+
tmdb_id: Optional[int] = None,
169+
imdb_id: Optional[str] = None,
170+
path: Optional[str] = None,
171+
move_files: bool = False,
172+
quality_profile: Optional[Union[str, int, "QualityProfile"]] = None,
173+
monitored: Optional[bool] = None,
174+
minimum_availability: Optional[str] = None,
175+
tags: Optional[List[Union[str, int, Tag]]] = None,
176+
apply_tags: str = "add"
177+
) -> Movie:
178+
""" Gets a :class:`~arrapi.objs.reload.Movie` by one of the IDs and edits it in Radarr.
179+
180+
Parameters:
181+
movie_id (Optional[int]): Search by Radarr Movie ID.
182+
tmdb_id (Optional[int]): Search by TMDb ID.
183+
imdb_id (Optional[int]): Search by IMDb ID.
184+
path (Optional[str]): Path to change the Movie to.
185+
move_files (bool): When changing the path do you want to move the files to the new path.
186+
quality_profile (Optional[Union[str, int, QualityProfile]]): Quality Profile to change the Movie to.
187+
monitored (Optional[bool]): Monitor the Movie.
188+
minimum_availability (Optional[str]): Minimum Availability to change the Movie to. Valid options are announced, inCinemas, released, or preDB.
189+
tags (Optional[List[Union[str, int, Tag]]]): Tags to be added, replaced, or removed from the Movie.
190+
apply_tags (str): How you want to edit the Tags. Valid options are add, replace, or remove.
191+
192+
Raises:
193+
:class:`ValueError`: When no ID is given or when theres no options given.
194+
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
195+
:class:`~arrapi.exceptions.NotFound`: When there's no movie with that ID or when the Movie hasn't been added to Radarr.
196+
"""
197+
movie = self.get_movie(movie_id=movie_id, tmdb_id=tmdb_id, imdb_id=imdb_id)
198+
movie.edit(path=path, move_files=move_files, quality_profile=quality_profile, monitored=monitored,
199+
minimum_availability=minimum_availability, tags=tags, apply_tags=apply_tags)
200+
return movie
201+
202+
def delete_movie(
203+
self,
204+
movie_id: Optional[int] = None,
205+
tmdb_id: Optional[int] = None,
206+
imdb_id: Optional[str] = None,
207+
addImportExclusion: bool = False,
208+
deleteFiles: bool = False
209+
) -> Movie:
210+
""" Gets a :class:`~arrapi.objs.reload.Movie` by one of the IDs and deletes it from Radarr.
211+
212+
Parameters:
213+
movie_id (Optional[int]): Search by Radarr Movie ID.
214+
tmdb_id (Optional[int]): Search by TMDb ID.
215+
imdb_id (Optional[int]): Search by IMDb ID.
216+
addImportExclusion (bool): Add Import Exclusion for this Movie.
217+
deleteFiles (bool): Delete Files for this Movie.
218+
219+
Returns:
220+
:class:`~arrapi.objs.reload.Movie`: Movie for the ID given.
221+
222+
Raises:
223+
:class:`ValueError`: When no ID is given.
224+
:class:`~arrapi.exceptions.NotFound`: When there's no movie with that ID or when the Movie hasn't been added to Radarr.
225+
"""
226+
movie = self.get_movie(movie_id=movie_id, tmdb_id=tmdb_id, imdb_id=imdb_id)
227+
movie.delete(addImportExclusion=addImportExclusion, deleteFiles=deleteFiles)
228+
return movie
229+
230+
def add_multiple_movies(self, ids: List[Union[int, str, Movie, Tuple[Union[int, str, Movie], str]]],
127231
root_folder: Union[str, int, RootFolder],
128232
quality_profile: Union[str, int, QualityProfile],
129233
monitor: bool = True,

arrapi/apis/sonarr.py

+115-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,121 @@ def search_series(self, term: str) -> List[Series]:
137137
"""
138138
return [Series(self, data=d) for d in self._raw.get_series_lookup(term)]
139139

140-
def add_multiple_series(self, ids: List[Union[Series, int]],
140+
def add_series(
141+
self,
142+
root_folder: Union[str, int, "RootFolder"],
143+
quality_profile: Union[str, int, "QualityProfile"],
144+
language_profile: Union[str, int, "LanguageProfile"],
145+
series_id: Optional[int] = None,
146+
tvdb_id: Optional[int] = None,
147+
monitor: str = "all",
148+
season_folder: bool = True,
149+
search: bool = True,
150+
unmet_search: bool = True,
151+
series_type: str = "standard",
152+
tags: Optional[List[Union[str, int, Tag]]] = None
153+
) -> Series:
154+
""" Gets a :class:`~arrapi.objs.reload.Series` by one of the IDs and adds it to Sonarr.
155+
156+
Parameters:
157+
root_folder (Union[str, int, RootFolder]): Root Folder for the Series.
158+
quality_profile (Union[str, int, QualityProfile]): Quality Profile for the Series.
159+
language_profile (Union[str, int, LanguageProfile]): Language Profile for the Series.
160+
series_id (Optional[int]): Search by Sonarr Series ID.
161+
tvdb_id (Optional[int]): Search by TVDb ID.
162+
monitor (bool): How to monitor the Series. Valid options are all, future, missing, existing, pilot, firstSeason, latestSeason, or none.
163+
season_folder (bool): Use Season Folders for the Series.
164+
search (bool): Start search for missing episodes of the Series after adding.
165+
unmet_search (bool): Start search for cutoff unmet episodes of the Series after adding.
166+
series_type (str): Series Type for the Series. Valid options are standard, daily, or anime.
167+
tags (Optional[List[Union[str, int, Tag]]]): Tags to be added to the Series.
168+
169+
Returns:
170+
:class:`~arrapi.objs.reload.Series`: Series for the ID given.
171+
172+
Raises:
173+
:class:`ValueError`: When no ID is given.
174+
:class:`~arrapi.exceptions.NotFound`: When there's no series with that ID.
175+
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
176+
:class:`~arrapi.exceptions.Exists`: When the Series already Exists in Sonarr.
177+
"""
178+
series = self.get_series(series_id=series_id, tvdb_id=tvdb_id)
179+
series.add(root_folder, quality_profile, language_profile, monitor=monitor, season_folder=season_folder,
180+
search=search, unmet_search=unmet_search, series_type=series_type, tags=tags)
181+
return series
182+
183+
def edit_series(
184+
self,
185+
series_id: Optional[int] = None,
186+
tvdb_id: Optional[int] = None,
187+
path: Optional[str] = None,
188+
move_files: bool = False,
189+
quality_profile: Optional[Union[str, int, "QualityProfile"]] = None,
190+
language_profile: Optional[Union[str, int, "LanguageProfile"]] = None,
191+
monitor: Optional[str] = None,
192+
monitored: Optional[bool] = None,
193+
season_folder: Optional[bool] = None,
194+
series_type: Optional[str] = None,
195+
tags: Optional[List[Union[str, int, Tag]]] = None,
196+
apply_tags: str = "add"
197+
) -> Series:
198+
""" Gets a :class:`~arrapi.objs.reload.Series` by one of the IDs and edits it in Sonarr.
199+
200+
Parameters:
201+
series_id (Optional[int]): Search by Sonarr Series ID.
202+
tvdb_id (Optional[int]): Search by TVDb ID.
203+
path (Optional[str]): Path to change the Series to.
204+
move_files (bool): When changing the path do you want to move the files to the new path.
205+
quality_profile (Optional[Union[str, int, QualityProfile]]): Quality Profile to change the Series to.
206+
language_profile (Optional[Union[str, int, LanguageProfile]]): Language Profile to change the Series to.
207+
monitor (Optional[str]): How you want the Series monitored. Valid options are all, future, missing, existing, pilot, firstSeason, latestSeason, or none.
208+
monitored (Optional[bool]): Monitor the Series.
209+
season_folder (Optional[bool]): Use Season Folders for the Series.
210+
series_type (Optional[str]): Series Type to change the Series to. Valid options are standard, daily, or anime.
211+
tags (Optional[List[Union[str, int, Tag]]]): Tags to be added, replaced, or removed from the Series.
212+
apply_tags (str): How you want to edit the Tags. Valid options are add, replace, or remove.
213+
214+
Returns:
215+
:class:`~arrapi.objs.reload.Series`: Series for the ID given.
216+
217+
Raises:
218+
:class:`ValueError`: When no ID is given or when theres no options given.
219+
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
220+
:class:`~arrapi.exceptions.NotFound`: When there's no series with that ID or when the Series hasn't been added to Sonarr.
221+
"""
222+
series = self.get_series(series_id=series_id, tvdb_id=tvdb_id)
223+
series.edit(path=path, move_files=move_files, quality_profile=quality_profile,
224+
language_profile=language_profile, monitor=monitor, monitored=monitored,
225+
season_folder=season_folder, series_type=series_type, tags=tags, apply_tags=apply_tags)
226+
return series
227+
228+
def delete_series(
229+
self,
230+
series_id: Optional[int] = None,
231+
tvdb_id: Optional[int] = None,
232+
addImportExclusion: bool = False,
233+
deleteFiles: bool = False
234+
) -> Series:
235+
""" Gets a :class:`~arrapi.objs.reload.Series` by one of the IDs and deletes it from Sonarr.
236+
237+
Parameters:
238+
series_id (Optional[int]): Search by Sonarr Series ID.
239+
tvdb_id (Optional[int]): Search by TVDb ID.
240+
addImportExclusion (bool): Add Import Exclusion for this Series.
241+
deleteFiles (bool): Delete Files for this Series.
242+
243+
Returns:
244+
:class:`~arrapi.objs.reload.Series`: Series for the ID given.
245+
246+
Raises:
247+
:class:`ValueError`: When no ID is given.
248+
:class:`~arrapi.exceptions.NotFound`: When there's no series with that ID or when the Series hasn't been added to Sonarr.
249+
"""
250+
series = self.get_series(series_id=series_id, tvdb_id=tvdb_id)
251+
series.delete(addImportExclusion=addImportExclusion, deleteFiles=deleteFiles)
252+
return series
253+
254+
def add_multiple_series(self, ids: List[Union[Series, int, Tuple[Union[Series, int], str]]],
141255
root_folder: Union[str, int, RootFolder],
142256
quality_profile: Union[str, int, QualityProfile],
143257
language_profile: Union[str, int, LanguageProfile],

arrapi/objs/reload.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def edit(self,
332332
Raises:
333333
:class:`ValueError`: When theres no options given.
334334
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
335-
:class:`~arrapi.exceptions.NotFound`: When the Movie isn't found in Radarr and must be added to Radarr before editing.
335+
:class:`~arrapi.exceptions.NotFound`: When the Movie hasn't been added to Radarr.
336336
"""
337337
if not self.id:
338338
raise NotFound(f"{self.title} not found Radarr, it must be added before editing")
@@ -363,7 +363,7 @@ def delete(self, addImportExclusion: bool = False, deleteFiles: bool = False) ->
363363
deleteFiles (bool): Delete Files for this Movie.
364364
365365
Raises:
366-
:class:`~arrapi.exceptions.NotFound`: When the Movie isn't found in Radarr.
366+
:class:`~arrapi.exceptions.NotFound`: When the Movie hasn't been added to Radarr.
367367
"""
368368
if not self.id:
369369
raise NotFound(f"{self.title} not found Radarr, it must be added before deleting")
@@ -594,7 +594,7 @@ def edit(self,
594594
Raises:
595595
:class:`ValueError`: When theres no options given.
596596
:class:`~arrapi.exceptions.Invalid`: When one of the options given is invalid.
597-
:class:`~arrapi.exceptions.NotFound`: When the Series isn't found in Sonarr and must be added to Sonarr before editing.
597+
:class:`~arrapi.exceptions.NotFound`: When the Series hasn't been added to Sonarr.
598598
"""
599599
if not self.id:
600600
raise NotFound(f"{self.title} not found in Sonarr, it must be added before editing")
@@ -628,7 +628,7 @@ def delete(self, addImportExclusion: bool = False, deleteFiles: bool = False) ->
628628
deleteFiles (bool): Delete Files for this Series.
629629
630630
Raises:
631-
:class:`~arrapi.exceptions.NotFound`: When the Series isn't found in Sonarr.
631+
:class:`~arrapi.exceptions.NotFound`: When the Series hasn't been added to Sonarr.
632632
"""
633633
if not self.id:
634634
raise NotFound(f"{self.title} not found in Sonarr, it must be added before deleting")

0 commit comments

Comments
 (0)