From b467653c0ec71d98bb5a742b31d53b9e457f06aa Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 14 Oct 2020 15:53:23 +0100 Subject: [PATCH] Add client parameter to pp class and add it to API sg.postprocess. Change API version to 14. --- CHANGES.md | 2 ++ sickbeard/processTV.py | 12 ++++++++---- sickbeard/webapi.py | 14 +++++++++++--- sickbeard/webserve.py | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1bf841c..cc581d1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ * Change remove `app` from URL when calling webhook * Change remind user when testing Notifications config / Discord to update URL * Fix incorrect text for some drop down list items in the apiBuilder view that affected some browsers +* Add client parameter to pp class and add it to API sg.postprocess +* Change API version to 14 * Change add a test for both require and ignore show specific words with partial match, both should fail * Change init showDict for all unit tests * Update attr 20.1.0.dev0 (4bd6827) to 20.2.0 (4f74fba) diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index 7b22299..00b03ed 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -58,7 +58,7 @@ if False: class ProcessTVShow(object): """ Process a TV Show """ - def __init__(self, webhandler=None, is_basedir=True, skip_failure_processing=False): + def __init__(self, webhandler=None, is_basedir=True, skip_failure_processing=False, client=None): self.files_passed = 0 # type: int self.files_failed = 0 # type: int self.fail_detected = False # type: bool @@ -66,6 +66,7 @@ class ProcessTVShow(object): self._output = [] # type: List self.webhandler = webhandler self.is_basedir = is_basedir # type: bool + self.client = client # type: Optional[AnyStr] @property def any_vid_processed(self): @@ -1161,7 +1162,7 @@ class ProcessTVShow(object): # backward compatibility prevents the case of this function name from being updated to PEP8 def processDir(dir_name, nzb_name=None, process_method=None, force=False, force_replace=None, failed=False, pp_type='auto', cleanup=False, webhandler=None, show_obj=None, is_basedir=True, - skip_failure_processing=False): + skip_failure_processing=False, client=None): """ :param dir_name: dir name @@ -1188,12 +1189,15 @@ def processDir(dir_name, nzb_name=None, process_method=None, force=False, force_ :type is_basedir: bool :param skip_failure_processing: :type skip_failure_processing: bool + :param client: string to represent the client + :type client: Optional[AnyStr] :return: :rtype: AnyStr """ # backward compatibility prevents the case of this function name from being updated to PEP8 - return ProcessTVShow(webhandler, is_basedir, skip_failure_processing=skip_failure_processing).process_dir( - dir_name, nzb_name, process_method, force, force_replace, failed, pp_type, cleanup, show_obj) + return ProcessTVShow(webhandler, is_basedir, skip_failure_processing=skip_failure_processing, + client=client).process_dir(dir_name, nzb_name, process_method, force, force_replace, failed, + pp_type, cleanup, show_obj) def process_minimal(nzb_name, show_obj, failed, webhandler): diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index b9d29a6..c398e12 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -129,7 +129,7 @@ class PythonObjectEncoder(json.JSONEncoder): class Api(webserve.BaseHandler): """ api class that returns json results """ - version = 13 # use an int since float-point is unpredictable + version = 14 # use an int since float-point is unpredictable indent = 4 def check_xsrf_cookie(self): @@ -1896,6 +1896,7 @@ class CMD_SickGearPostProcess(ApiCall): "is_priority": {"desc": "Replace file(s) even if existing at a higher quality"}, "type": {"desc": "Type of media process request this is, auto or manual"}, "failed": {"desc": "Mark as failed download"}, + "client": {"desc": "String representing the calling client"}, } } @@ -1908,8 +1909,9 @@ class CMD_SickGearPostProcess(ApiCall): self.process_method, args = self.check_params(args, kwargs, "process_method", False, False, "string", [ "copy", "symlink", "hardlink", "move"]) self.is_priority, args = self.check_params(args, kwargs, "is_priority", 0, False, "bool", []) - self.type, args = self.check_params(args, kwargs, "type", "auto", None, "string", ["auto", "manual"]) + self.type, args = self.check_params(args, kwargs, "type", "auto", False, "string", ["auto", "manual"]) self.failed, args = self.check_params(args, kwargs, "failed", 0, False, "bool", []) + self.client, args = self.check_params(args, kwargs, "client", None, False, "string", []) # super, missing, help ApiCall.__init__(self, handler, args, kwargs) @@ -1925,7 +1927,8 @@ class CMD_SickGearPostProcess(ApiCall): self.type = 'manual' data = processTV.processDir(self.path, process_method=self.process_method, force=self.force_replace, - force_replace=self.is_priority, failed=self.failed, pp_type=self.type) + force_replace=self.is_priority, failed=self.failed, pp_type=self.type, + client=self.client) if not self.return_data: data = "" @@ -1951,6 +1954,11 @@ class CMD_PostProcess(CMD_SickGearPostProcess): # super, missing, help self.sickbeard_call = True kwargs['failed'] = "0" + try: + if 'client' in kwargs: + del kwargs['client'] + except (BaseException, Exception): + pass CMD_SickGearPostProcess.__init__(self, handler, args, kwargs) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 3380e8e..ccc1e73 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3323,7 +3323,7 @@ class HomeProcessMedia(Home): failed='0' != failed, webhandler=None if '0' == stream else self.send_message, show_obj=show_obj, is_basedir=is_basedir in ('on', '1'), - skip_failure_processing=skip_failure_processing) + skip_failure_processing=skip_failure_processing, client=client) if '0' == stream: regexp = re.compile(r'(?i)', flags=re.UNICODE)