From ace655f2d890baacf318026d776773152ff5d492 Mon Sep 17 00:00:00 2001 From: Archmonger <16909269+Archmonger@users.noreply.github.com> Date: Fri, 5 Nov 2021 02:45:59 -0700 Subject: [PATCH] Refactor using Sourcery (#90) * Refactor using Sourcery * bump version --- pyarr/radarr_api.py | 222 ++++++++++++++------------------------------ pyarr/sonarr_api.py | 126 ++++++++----------------- pyproject.toml | 2 +- 3 files changed, 108 insertions(+), 242 deletions(-) diff --git a/pyarr/radarr_api.py b/pyarr/radarr_api.py index e2204a7..ad1ac73 100644 --- a/pyarr/radarr_api.py +++ b/pyarr/radarr_api.py @@ -41,7 +41,7 @@ def _construct_movie_json( if not movie: raise Exception("Movie Doesn't Exist") - movie_json = { + return { "title": movie["title"], "rootFolderPath": root_dir, "qualityProfileId": quality_profile_id, @@ -52,7 +52,6 @@ def _construct_movie_json( "monitored": monitored, "addOptions": {"searchForMovie": search_for_movie}, } - return movie_json ## MOVIE @@ -70,8 +69,7 @@ def get_movie(self, id_=None): if id_: params["tmdbId"] = id_ path = "/api/v3/movie" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # POST /movie def add_movie( @@ -101,8 +99,7 @@ def add_movie( ) path = "/api/v3/movie" - res = self.request_post(path, data=movie_json) - return res + return self.request_post(path, data=movie_json) # PUT /movie def upd_movie(self, data, move_files=False): @@ -118,8 +115,7 @@ def upd_movie(self, data, move_files=False): path = "/api/v3/movie" params = {"moveFiles": move_files} - res = self.request_put(path, data=data, params=params) - return res + return self.request_put(path, data=data, params=params) # GET /movie/{id} def get_movie_by_movie_id(self, id_): @@ -132,8 +128,7 @@ def get_movie_by_movie_id(self, id_): JSON: Movie data if present in database """ path = f"/api/v3/movie/{id_}" - res = self.request_get(path) - return res + return self.request_get(path) # DELETE /movie/{id} def del_movie(self, id_, delete_files=False, add_exclusion=False): @@ -149,8 +144,7 @@ def del_movie(self, id_, delete_files=False, add_exclusion=False): """ params = {"deleteFiles": delete_files, "addExclusion": add_exclusion} path = f"/api/v3/movie/{id_}" - res = self.request_del(path, params=params) - return res + return self.request_del(path, params=params) # GET /movie/lookup def lookup_movie(self, term): @@ -164,8 +158,7 @@ def lookup_movie(self, term): """ params = {"term": term} path = "/api/v3/movie/lookup" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /movie/lookup def lookup_movie_by_tmdb_id(self, id_): @@ -179,8 +172,7 @@ def lookup_movie_by_tmdb_id(self, id_): """ params = {"term": f"tmdb:{id_}"} path = "/api/v3/movie/lookup" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /movie/lookup def lookup_movie_by_imdb_id(self, id_): @@ -194,8 +186,7 @@ def lookup_movie_by_imdb_id(self, id_): """ params = {"term": f"imdb:{id_}"} path = "/api/v3/movie/lookup" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # PUT /movie/editor def upd_movies(self, data): @@ -208,8 +199,7 @@ def upd_movies(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/movie/editor" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /movie/editor def del_movies(self, data): @@ -230,8 +220,7 @@ def del_movies(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/movie/editor" - res = self.request_del(path, data=data) - return res + return self.request_del(path, data=data) # POST /movie/import def import_movies(self, data): @@ -244,8 +233,7 @@ def import_movies(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/movie/import" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) ## MOVIEFILE @@ -261,8 +249,7 @@ def get_movie_files_by_movie_id(self, id_): """ params = {"movieid": id_} path = "/api/v3/moviefile" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /moviefile def get_movie_files(self, moviefile_ids): @@ -276,8 +263,7 @@ def get_movie_files(self, moviefile_ids): """ params = {"moviefileids": moviefile_ids} path = "/api/v3/moviefile" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /moviefile/{id} def get_movie_file(self, id_): @@ -290,8 +276,7 @@ def get_movie_file(self, id_): JSON: movie file information """ path = f"/api/v3/moviefile/{id_}" - res = self.request_get(path) - return res + return self.request_get(path) # DELETE /moviefile/{id} def del_movie_file(self, id_): @@ -304,8 +289,7 @@ def del_movie_file(self, id_): JSON: 200 Ok, 401 Unauthorized """ path = f"/api/v3/moviefile/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## HISTORY @@ -331,8 +315,7 @@ def get_history( "sortKey": sort_key, } path = "/api/v3/history" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /history/movie def get_movie_history(self, id_, event_type=None): @@ -349,8 +332,7 @@ def get_movie_history(self, id_, event_type=None): if event_type: params["eventType"] = event_type path = "/api/v3/history/movie" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## BLACKLIST @@ -380,8 +362,7 @@ def get_blacklist( "sortKey": sort_key, } path = "/api/v3/blacklist" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # DELETE /blacklist def del_blacklist(self, id_): @@ -395,8 +376,7 @@ def del_blacklist(self, id_): """ params = {"id": id_} path = "/api/v3/blacklist" - res = self.request_del(path, params=params) - return res + return self.request_del(path, params=params) # GET /blacklist/movie def get_blacklist_by_movie_id( @@ -413,8 +393,7 @@ def get_blacklist_by_movie_id( """ params = {"movieId": id_} path = "/api/v3/blacklist/movie" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # DELETE /blacklist/bulk def del_blacklist_bulk(self, data): @@ -427,8 +406,7 @@ def del_blacklist_bulk(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/blacklist/bulk" - res = self.request_del(path, data=data) - return res + return self.request_del(path, data=data) ## QUEUE @@ -461,8 +439,7 @@ def get_queue( "includeUnknownMovieItems": include_unknown_movie_items, } path = "/api/v3/queue" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # DELETE /queue/{id} def del_queue(self, id_, remove_from_client=True, blacklist=True): @@ -478,8 +455,7 @@ def del_queue(self, id_, remove_from_client=True, blacklist=True): """ params = {"removeFromClient": remove_from_client, "blacklist": blacklist} path = f"/api/v3/queue/{id_}" - res = self.request_del(path, params=params) - return res + return self.request_del(path, params=params) # DELETE /queue/bulk def del_queue_bulk(self, data, remove_from_client=True, blacklist=True): @@ -502,8 +478,7 @@ def del_queue_bulk(self, data, remove_from_client=True, blacklist=True): """ params = {"removeFromClient": remove_from_client, "blacklist": blacklist} path = "/api/v3/queue/bulk" - res = self.request_del(path, params=params, data=data) - return res + return self.request_del(path, params=params, data=data) # GET /queue/details def get_queue_details( @@ -522,8 +497,7 @@ def get_queue_details( "includeMovie": include_movie, } path = "/api/v3/queue/details" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /queue/status def get_queue_status(self): @@ -533,8 +507,7 @@ def get_queue_status(self): JSON: Array """ path = "/api/v3/queue/status" - res = self.request_get(path) - return res + return self.request_get(path) # POST /queue/grab/{id} def force_grab_queue_item(self, id_): @@ -547,8 +520,7 @@ def force_grab_queue_item(self, id_): JSON: 200 ok, 401 Invalid API Key """ path = f"/api/v3/queue/grab/{id_}" - res = self.request_post(path) - return res + return self.request_post(path) ## INDEXER @@ -562,13 +534,8 @@ def get_indexer(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/indexer" - else: - path = f"/api/v3/indexer/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/indexer" if not id_ else f"/api/v3/indexer/{id_}" + return self.request_get(path) # PUT /indexer/{id} def upd_indexer(self, id_, data): @@ -582,8 +549,7 @@ def upd_indexer(self, id_, data): JSON: 200 ok, 401 Unauthorized """ path = f"/api/v3/indexer/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /indexer/{id} def del_indexer(self, id_): @@ -596,8 +562,7 @@ def del_indexer(self, id_): JSON: 200 Ok, 401 Unauthorized """ path = f"/api/v3/indexer/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## DOWNLOAD CLIENT @@ -611,13 +576,8 @@ def get_download_client(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/downloadclient" - else: - path = f"/api/v3/downloadclient/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/downloadclient" if not id_ else f"/api/v3/downloadclient/{id_}" + return self.request_get(path) # PUT /downloadclient/{id} def upd_download_client(self, id_, data): @@ -631,8 +591,7 @@ def upd_download_client(self, id_, data): JSON: 200 Ok """ path = f"/api/v3/downloadclient/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /downloadclient/{id} def del_download_client(self, id_): @@ -645,8 +604,7 @@ def del_download_client(self, id_): JSON: 200 Ok """ path = f"/api/v3/downloadclient/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## IMPORT LISTS @@ -660,13 +618,8 @@ def get_import_list(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/importlist" - else: - path = f"/api/v3/importlist/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/importlist" if not id_ else f"/api/v3/importlist/{id_}" + return self.request_get(path) # PUT /importlist/{id} def upd_import_list(self, id_, data): @@ -680,8 +633,7 @@ def upd_import_list(self, id_, data): JSON: 200 Ok, 401 Unauthorized """ path = f"/api/v3/importlist/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /importlist/{id} def del_import_list(self, id_): @@ -694,8 +646,7 @@ def del_import_list(self, id_): JSON: 200 ok, 401 Unauthorized """ path = f"/api/v3/importlist/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## NOTIFICATION @@ -709,13 +660,8 @@ def get_notification(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/notification" - else: - path = f"/api/v3/notification/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/notification" if not id_ else f"/api/v3/notification/{id_}" + return self.request_get(path) # PUT /notification/{id} def upd_notification(self, id_, data): @@ -729,8 +675,7 @@ def upd_notification(self, id_, data): JSON: 200 Ok, 401 Unauthorized """ path = f"/api/v3/notification/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /notification/{id} def del_notification(self, id_): @@ -743,8 +688,7 @@ def del_notification(self, id_): JSON: 201 Ok, 401 Unauthorized """ path = f"/api/v3/notification/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## TAG @@ -758,13 +702,8 @@ def get_tag(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/tag" - else: - path = f"/api/v3/tag/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/tag" if not id_ else f"/api/v3/tag/{id_}" + return self.request_get(path) # POST /tag def create_tag(self, label): @@ -778,8 +717,7 @@ def create_tag(self, label): """ data = {"id": 0, "label": label} path = "/api/v3/tag" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) # PUT /tag/{id} def upd_tag(self, id_, label): @@ -794,8 +732,7 @@ def upd_tag(self, id_, label): """ data = {"id": id_, "label": label} path = f"/api/v3/tag/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /tag/{id} def del_tag(self, id_): @@ -808,8 +745,7 @@ def del_tag(self, id_): JSON: 200 Ok, 401 Unauthorized """ path = f"/api/v3/tag/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) # GET /tag/detail and /tag/detail/{id} def get_tag_details(self, id_=None): @@ -822,13 +758,8 @@ def get_tag_details(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/v3/tag/detail" - else: - path = f"/api/v3/tag/detail/{id_}" - - res = self.request_get(path) - return res + path = "/api/v3/tag/detail" if not id_ else f"/api/v3/tag/detail/{id_}" + return self.request_get(path) ## DISKSPACE @@ -841,8 +772,7 @@ def get_disk_space(self): JSON: Array """ path = "/api/v3/diskspace" - res = self.request_get(path) - return res + return self.request_get(path) ## SETTINGS @@ -854,8 +784,7 @@ def get_config_ui(self): JSON: Array """ path = "/api/v3/config/ui" - res = self.request_get(path) - return res + return self.request_get(path) # PUT /config/ui def upd_config_ui(self, data): @@ -868,8 +797,7 @@ def upd_config_ui(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/config/ui" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # GET /config/host def get_config_host(self): @@ -879,8 +807,7 @@ def get_config_host(self): JSON: Array """ path = "/api/v3/config/host" - res = self.request_get(path) - return res + return self.request_get(path) # PUT /config/host def upd_config_host(self, data): @@ -893,8 +820,7 @@ def upd_config_host(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/config/host" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # GET /config/naming def get_config_naming(self): @@ -904,8 +830,7 @@ def get_config_naming(self): JSON: Array """ path = "/api/v3/config/naming" - res = self.request_get(path) - return res + return self.request_get(path) # PUT /config/naming def upd_config_naming(self, data): @@ -918,8 +843,7 @@ def upd_config_naming(self, data): JSON: 200 Ok, 401 Unauthorized """ path = "/api/v3/config/naming" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) ## METADATA @@ -931,8 +855,7 @@ def get_metadata(self): JSON: Array """ path = "/api/v3/metadata" - res = self.request_get(path) - return res + return self.request_get(path) ## SYSTEM @@ -944,8 +867,7 @@ def get_system_status(self): JSON: Array """ path = "/api/v3/system/status" - res = self.request_get(path) - return res + return self.request_get(path) ## HEALTH @@ -957,8 +879,7 @@ def get_health(self): JSON: Array """ path = "/api/v3/health" - res = self.request_get(path) - return res + return self.request_get(path) ## COMMAND @@ -982,8 +903,7 @@ def post_command(self, name, **kwargs): **kwargs, } path = "/api/v3/command" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) ## UPDATE @@ -995,8 +915,7 @@ def get_updates(self): JSON: Array """ path = "/api/v3/update" - res = self.request_get(path) - return res + return self.request_get(path) ## QUALITY PROFILE @@ -1008,8 +927,7 @@ def get_quality_profiles(self): JSON: Array """ path = "/api/v3/qualityProfile" - res = self.request_get(path) - return res + return self.request_get(path) ## CALENDAR @@ -1031,8 +949,7 @@ def get_calendar(self, start_date, end_date, unmonitored=True): "unmonitored": unmonitored, } path = "/api/v3/calendar" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## CUSTOM FILTERS @@ -1044,8 +961,7 @@ def get_custom_filter(self): JSON: Array """ path = "/api/v3/customfilter" - res = self.request_get(path) - return res + return self.request_get(path) ## REMOTE PATH MAPPING @@ -1057,8 +973,7 @@ def get_remote_path_mapping(self): JSON: Array """ path = "/api/v3/remotePathMapping" - res = self.request_get(path) - return res + return self.request_get(path) ## ROOT FOLDER @@ -1070,5 +985,4 @@ def get_root_folder(self): JSON: Array """ path = "/api/v3/rootfolder" - res = self.request_get(path) - return res + return self.request_get(path) diff --git a/pyarr/sonarr_api.py b/pyarr/sonarr_api.py index 8408b62..c6a0404 100644 --- a/pyarr/sonarr_api.py +++ b/pyarr/sonarr_api.py @@ -37,7 +37,7 @@ def _construct_series_json( for season in series["seasons"]: season["monitored"] = False - series_json = { + return { "title": series["title"], "seasons": series["seasons"], "rootFolderPath": root_dir, @@ -53,7 +53,6 @@ def _construct_series_json( "searchForMissingEpisodes": search_for_missing_episodes, }, } - return series_json ## CALENDAR @@ -77,8 +76,7 @@ def get_calendar(self, start_date=None, end_date=None): if end_date: params["end"] = datetime.strptime(end_date, "%Y-%m-%d").strftime("%Y-%m-%d") - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## COMMAND @@ -92,13 +90,8 @@ def get_command(self, id_=None): Returns: JSON: Array """ - if id_: - path = f"/api/command/{id_}" - else: - path = "/api/command" - - res = self.request_get(path) - return res + path = f"/api/command/{id_}" if id_ else "/api/command" + return self.request_get(path) # POST /command def post_command(self, name, **kwargs): @@ -122,8 +115,7 @@ def post_command(self, name, **kwargs): "name": name, **kwargs, } - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) ## DISKSPACE @@ -135,8 +127,7 @@ def get_disk_space(self): JSON: Array """ path = "/api/diskspace" - res = self.request_get(path) - return res + return self.request_get(path) ## EPISODE @@ -152,8 +143,7 @@ def get_episodes_by_series_id(self, id_): """ path = "/api/episode" params = {"seriesId": id_} - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /episode/{id} def get_episode_by_episode_id(self, id_): @@ -166,8 +156,7 @@ def get_episode_by_episode_id(self, id_): JSON: Array """ path = f"/api/episode/{id_}" - res = self.request_get(path) - return res + return self.request_get(path) # PUT /episode def upd_episode(self, data): @@ -183,8 +172,7 @@ def upd_episode(self, data): JSON: Array """ path = "/api/episode" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) ## EPISODE FILE @@ -200,8 +188,7 @@ def get_episode_files_by_series_id(self, id_): """ path = "/api/episodefile" params = {"seriesId": id_} - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /episodefile/{id} def get_episode_file(self, id_): @@ -214,8 +201,7 @@ def get_episode_file(self, id_): JSON: Array """ path = f"/api/episodefile/{id_}" - res = self.request_get(path) - return res + return self.request_get(path) # DELETE /episodefile/{id} def del_episode_file(self, id_): @@ -228,8 +214,7 @@ def del_episode_file(self, id_): JSON: {} """ path = f"/api/episodefile/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) # PUT /episodefile/{id} def upd_episode_file_quality(self, id_, data): @@ -255,8 +240,7 @@ def upd_episode_file_quality(self, id_, data): JSON: Array """ path = f"/api/episodefile/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) ## HISTORY @@ -285,8 +269,7 @@ def get_history( } if id_: params["episodeId"] = id_ - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## WANTED (MISSING) @@ -310,8 +293,7 @@ def get_wanted(self, sort_key="airDateUtc", page=1, page_size=10, sort_dir="asc" "pageSize": page_size, "sortDir": sort_dir, } - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## QUEUE @@ -323,8 +305,7 @@ def get_queue(self): JSON: Array """ path = "/api/queue" - res = self.request_get(path) - return res + return self.request_get(path) # DELETE /queue def del_queue(self, id_, blacklist=False): @@ -339,8 +320,7 @@ def del_queue(self, id_, blacklist=False): """ params = {"id": id_, "blacklist": blacklist} path = "/api/queue/" - res = self.request_del(path, params=params) - return res + return self.request_del(path, params=params) ## PARSE @@ -359,8 +339,7 @@ def get_parsed_title(self, title): """ params = {"title": title} path = "/api/parse" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /parse def get_parsed_path(self, file_path): @@ -377,8 +356,7 @@ def get_parsed_path(self, file_path): """ params = {"path": file_path} path = "/api/parse" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## PROFILE @@ -390,8 +368,7 @@ def get_quality_profiles(self): JSON: Array """ path = "/api/profile" - res = self.request_get(path) - return res + return self.request_get(path) ## RELEASE @@ -407,8 +384,7 @@ def get_releases(self, id_): """ params = {"episodeId": id_} path = "/api/release" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # POST /release def download_release(self, guid, indexer_id): @@ -425,8 +401,7 @@ def download_release(self, guid, indexer_id): """ data = {"guid": guid, "indexerId": indexer_id} path = "/api/release" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) # POST /release/push def push_release(self, title, download_url, protocol, publish_date): @@ -448,8 +423,7 @@ def push_release(self, title, download_url, protocol, publish_date): "publishDate": publish_date, } path = "/api/release/push" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) ## ROOT FOLDER @@ -461,8 +435,7 @@ def get_root_folder(self): JSON: Array """ path = "/api/rootfolder" - res = self.request_get(path) - return res + return self.request_get(path) ## SERIES # GET /series and /series/{id} @@ -476,13 +449,8 @@ def get_series(self, id_=None): Returns: JSON: Array """ - if id_: - path = f"/api/series/{id_}" - else: - path = "/api/series" - - res = self.request_get(path) - return res + path = f"/api/series/{id_}" if id_ else "/api/series" + return self.request_get(path) # POST /series def add_series( @@ -527,8 +495,7 @@ def add_series( ) path = "/api/series" - res = self.request_post(path, data=series_json) - return res + return self.request_post(path, data=series_json) # PUT /series def upd_series(self, data): @@ -541,8 +508,7 @@ def upd_series(self, data): JSON: Array """ path = "/api/series" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /series/{id} def del_series(self, id_, delete_files=False): @@ -558,8 +524,7 @@ def del_series(self, id_, delete_files=False): # File deletion does not work params = {"deleteFiles": delete_files} path = f"/api/series/{id_}" - res = self.request_del(path, params=params) - return res + return self.request_del(path, params=params) # GET /series/lookup def lookup_series(self, term): @@ -573,8 +538,7 @@ def lookup_series(self, term): """ params = {"term": term} path = "/api/series/lookup" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) # GET /series/lookup def lookup_series_by_tvdb_id(self, id_): @@ -588,8 +552,7 @@ def lookup_series_by_tvdb_id(self, id_): """ params = {"term": f"tvdb:{id_}"} path = "/api/series/lookup" - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) ## SYSTEM @@ -601,8 +564,7 @@ def get_system_status(self): JSON: Array """ path = "/api/system/status" - res = self.request_get(path) - return res + return self.request_get(path) # GET /system/backup def get_backup(self): @@ -612,8 +574,7 @@ def get_backup(self): JSON: Array """ path = "/api/system/backup" - res = self.request_get(path) - return res + return self.request_get(path) ## TAG @@ -627,13 +588,8 @@ def get_tag(self, id_=None): Returns: JSON: Array """ - if not id_: - path = "/api/tag" - else: - path = f"/api/tag/{id_}" - - res = self.request_get(path) - return res + path = "/api/tag" if not id_ else f"/api/tag/{id_}" + return self.request_get(path) # POST /tag def create_tag(self, label): @@ -647,8 +603,7 @@ def create_tag(self, label): """ data = {"label": label} path = "/api/tag" - res = self.request_post(path, data=data) - return res + return self.request_post(path, data=data) # PUT /tag/{id} def upd_tag(self, id_, label): @@ -666,8 +621,7 @@ def upd_tag(self, id_, label): """ data = {"id": id_, "label": label} path = f"/api/tag/{id_}" - res = self.request_put(path, data=data) - return res + return self.request_put(path, data=data) # DELETE /tag/{id} def del_tag(self, id_): @@ -680,8 +634,7 @@ def del_tag(self, id_): JSON: {} """ path = f"/api/tag/{id_}" - res = self.request_del(path) - return res + return self.request_del(path) ## LOG @@ -717,5 +670,4 @@ def get_logs( "filterKey": filter_key, "filterValue": filter_value, } - res = self.request_get(path, params=params) - return res + return self.request_get(path, params=params) diff --git a/pyproject.toml b/pyproject.toml index fb6fa43..018b102 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyarr" -version = "2.0.7" +version = "2.0.8" description = "A Sonarr and Radarr API Wrapper" authors = ["Steven Marks "] license = "MIT"