From c2e3cd868986a11c978fce12c0e6794ebc33cc51 Mon Sep 17 00:00:00 2001 From: joshjowen Date: Fri, 25 Apr 2014 15:49:28 +1000 Subject: [PATCH 1/3] Fixed addshow and addexisting Api commands to work with indexer --- sickbeard/webapi.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index e4203ae3..d3dc0ed8 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1784,6 +1784,7 @@ class CMD_Show(ApiCall): class CMD_ShowAddExisting(ApiCall): _help = {"desc": "add a show in sickbeard with an existing folder", "requiredParameters": {"indexerid": {"desc": "thetvdb.com unique id of a show"}, + "indexer": {"desc": "Indexer to use 1:thetvdb.com 2:tvrage.com"}, "location": {"desc": "full path to the existing folder for the show"} }, "optionalParameters": {"initial": {"desc": "initial quality for the show"}, @@ -1797,6 +1798,7 @@ class CMD_ShowAddExisting(ApiCall): # required self.location, args = self.check_params(args, kwargs, "location", None, True, "string", []) self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", []) + self.indexer, args = self.check_params(args, kwargs, "indexer", None, True, "int", []) # optional self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", @@ -1821,7 +1823,7 @@ class CMD_ShowAddExisting(ApiCall): return _responds(RESULT_FAILURE, msg='Not a valid location') indexerName = None - indexerResult = CMD_SickBeardSearchIndexers([], {"indexerid": self.indexerid}).run() + indexerResult = CMD_SickBeardSearchIndexers([], {"indexerid": self.indexerid, "indexer": self.indexer}).run() if indexerResult['result'] == result_type_map[RESULT_SUCCESS]: if not indexerResult['data']['results']: @@ -1858,14 +1860,15 @@ class CMD_ShowAddExisting(ApiCall): if iqualityID or aqualityID: newQuality = Quality.combineQualities(iqualityID, aqualityID) - sickbeard.showQueueScheduler.action.addShow(int(self.indexerid), self.location, SKIPPED, newQuality, + sickbeard.showQueueScheduler.action.addShow(int(self.indexer), int(self.indexerid), self.location, SKIPPED, newQuality, int(self.flatten_folders)) #@UndefinedVariable return _responds(RESULT_SUCCESS, {"name": indexerName}, indexerName + " has been queued to be added") class CMD_ShowAddNew(ApiCall): _help = {"desc": "add a new show to sickbeard", - "requiredParameters": {"indexerid": {"desc": "thetvdb.com or tvrage.com unique id of a show"} + "requiredParameters": {"indexerid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}, + "indexer": {"desc": "Indexer to use 1:thetvdb.com 2:tvrage.com"} }, "optionalParameters": {"initial": {"desc": "initial quality for the show"}, "location": {"desc": "base path for where the show folder is to be created"}, @@ -1886,6 +1889,7 @@ class CMD_ShowAddNew(ApiCall): def __init__(self, args, kwargs): # required self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", []) + self.indexer, args = self.check_params(args, kwargs, "indexer", None, True, "int", []) # optional self.location, args = self.check_params(args, kwargs, "location", None, False, "string", []) self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", @@ -1965,7 +1969,7 @@ class CMD_ShowAddNew(ApiCall): newStatus = self.status indexerName = None - indexerResult = CMD_SickBeardSearchTVDB([], {"indexerid": self.indexerid}).run() + indexerResult = CMD_SickBeardSearchIndexers([], {"indexerid": self.indexerid, "indexer": self.indexer}).run() if indexerResult['result'] == result_type_map[RESULT_SUCCESS]: if not indexerResult['data']['results']: @@ -1991,7 +1995,7 @@ class CMD_ShowAddNew(ApiCall): else: helpers.chmodAsParent(showPath) - sickbeard.showQueueScheduler.action.addShow(int(self.indexerid), showPath, newStatus, newQuality, + sickbeard.showQueueScheduler.action.addShow(int(self.indexer), int(self.indexerid), showPath, newStatus, newQuality, int(self.flatten_folders), self.subtitles, self.lang) #@UndefinedVariable return _responds(RESULT_SUCCESS, {"name": indexerName}, indexerName + " has been queued to be added") From c86bb23c01d03f286d27e78edd79e584e6afc093 Mon Sep 17 00:00:00 2001 From: joshjowen Date: Sat, 26 Apr 2014 09:14:24 +1000 Subject: [PATCH 2/3] WebApi addshow and add existing fixes --- sickbeard/webapi.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index d3dc0ed8..782e7640 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1783,8 +1783,7 @@ class CMD_Show(ApiCall): class CMD_ShowAddExisting(ApiCall): _help = {"desc": "add a show in sickbeard with an existing folder", - "requiredParameters": {"indexerid": {"desc": "thetvdb.com unique id of a show"}, - "indexer": {"desc": "Indexer to use 1:thetvdb.com 2:tvrage.com"}, + "requiredParameters": {"tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com id"}, "location": {"desc": "full path to the existing folder for the show"} }, "optionalParameters": {"initial": {"desc": "initial quality for the show"}, @@ -1795,10 +1794,16 @@ class CMD_ShowAddExisting(ApiCall): } def __init__(self, args, kwargs): + if "tvdbid" in args or "tvdbid" in kwargs: + _INDEXER_INT = 1 + _INDEXER = "tvdbid" + elif "tvrageid" in args or "tvrageid" in kwargs: + _INDEXER_INT = 2 + _INDEXER = "tvrageid" # required + self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", []) + self.indexer = _INDEXER_INT self.location, args = self.check_params(args, kwargs, "location", None, True, "string", []) - self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", []) - self.indexer, args = self.check_params(args, kwargs, "indexer", None, True, "int", []) # optional self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", @@ -1867,8 +1872,7 @@ class CMD_ShowAddExisting(ApiCall): class CMD_ShowAddNew(ApiCall): _help = {"desc": "add a new show to sickbeard", - "requiredParameters": {"indexerid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}, - "indexer": {"desc": "Indexer to use 1:thetvdb.com 2:tvrage.com"} + "requiredParameters": {"tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com id"} }, "optionalParameters": {"initial": {"desc": "initial quality for the show"}, "location": {"desc": "base path for where the show folder is to be created"}, @@ -1887,9 +1891,15 @@ class CMD_ShowAddNew(ApiCall): 'sv': 8, 'sl': 30} def __init__(self, args, kwargs): + if "tvdbid" in args or "tvdbid" in kwargs: + _INDEXER_INT = 1 + _INDEXER = "tvdbid" + elif "tvrageid" in args or "tvrageid" in kwargs: + _INDEXER_INT = 2 + _INDEXER = "tvrageid" # required - self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", []) - self.indexer, args = self.check_params(args, kwargs, "indexer", None, True, "int", []) + self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", []) + self.indexer = _INDEXER_INT # optional self.location, args = self.check_params(args, kwargs, "location", None, False, "string", []) self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", From 97088b34537a30d01dffe15d3fa940b1e22e67b2 Mon Sep 17 00:00:00 2001 From: joshjowen Date: Sat, 26 Apr 2014 09:39:53 +1000 Subject: [PATCH 3/3] WebApi addshow and add existing fixes --- sickbeard/webapi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 782e7640..9d749a05 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1800,6 +1800,9 @@ class CMD_ShowAddExisting(ApiCall): elif "tvrageid" in args or "tvrageid" in kwargs: _INDEXER_INT = 2 _INDEXER = "tvrageid" + else: + _INDEXER_INT = None + _INDEXER = None # required self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", []) self.indexer = _INDEXER_INT @@ -1897,6 +1900,9 @@ class CMD_ShowAddNew(ApiCall): elif "tvrageid" in args or "tvrageid" in kwargs: _INDEXER_INT = 2 _INDEXER = "tvrageid" + else: + _INDEXER_INT = None + _INDEXER = None # required self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", []) self.indexer = _INDEXER_INT