From a8a4296ce232be386749f1e8daaa55f9575db14f Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Mon, 13 Apr 2020 13:23:25 -0400 Subject: [PATCH 1/2] First commit of new postprocessing option --- medusa/app.py | 1 + medusa/post_processor.py | 10 ++++++++-- medusa/server/api/v2/config.py | 2 ++ .../slim/src/components/config-post-processing.vue | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/medusa/app.py b/medusa/app.py index 151071edf7..24d27347fa 100644 --- a/medusa/app.py +++ b/medusa/app.py @@ -283,6 +283,7 @@ def __init__(self): self.PROCESS_METHOD = None self.DELRARCONTENTS = False self.MOVE_ASSOCIATED_FILES = False + self.PROCESS_IF_FILE_SIZE_DIFFERENT = False self.POSTPONE_IF_SYNC_FILES = True self.POSTPONE_IF_NO_SUBS = False self.NFO_RENAME = True diff --git a/medusa/post_processor.py b/medusa/post_processor.py index 589a0acf0e..f59162db36 100644 --- a/medusa/post_processor.py +++ b/medusa/post_processor.py @@ -905,7 +905,7 @@ def _is_priority(self, old_ep_quality, new_ep_quality): return any([self.in_history, self.is_priority, self.manually_searched]) @staticmethod - def _should_process(current_quality, new_quality, allowed, preferred): + def _should_process(current_quality, new_quality, allowed, preferred, existing_file_status): """ Determine if a quality should be processed according to the quality system. @@ -918,6 +918,7 @@ def _should_process(current_quality, new_quality, allowed, preferred): :param new_quality: The new quality of the episode that is being processed :param allowed: Qualities that are allowed :param preferred: Qualities that are preferred + :param existing_file_status: PostProcessor enum with existing file status :return: Tuple with Boolean if the quality should be processed and String with reason if should process or not """ if new_quality in preferred: @@ -927,6 +928,8 @@ def _should_process(current_quality, new_quality, allowed, preferred): elif new_quality < current_quality: return False, 'New quality is lower than current Preferred. Ignoring quality' else: + if existing_file_status != PostProcessor.EXISTS_SAME: + return True, 'New size is different. Accepting quality' return False, 'New quality is equal than current Preferred. Ignoring quality' return True, 'New quality is Preferred' elif new_quality in allowed: @@ -939,6 +942,8 @@ def _should_process(current_quality, new_quality, allowed, preferred): elif new_quality < current_quality: return False, 'New quality is lower than current Allowed. Ignoring quality' else: + if existing_file_status != PostProcessor.EXISTS_SAME: + return True, 'New size is different. Accepting quality' return False, 'New quality is equal to current Allowed. Ignoring quality' else: return False, 'New quality is not in Allowed|Preferred. Ignoring quality' @@ -1081,7 +1086,8 @@ def process(self): (Quality.qualityStrings[new_ep_quality], Quality.qualityStrings[old_ep_quality])) should_process, should_process_reason = self._should_process(old_ep_quality, new_ep_quality, - allowed_qualities, preferred_qualities) + allowed_qualities, preferred_qualities, + existing_file_status) if not should_process: raise EpisodePostProcessingFailedException( u'File exists. Marking it unsafe to replace. Reason: {0}'.format(should_process_reason)) diff --git a/medusa/server/api/v2/config.py b/medusa/server/api/v2/config.py index 058bb61e40..a5335d372f 100644 --- a/medusa/server/api/v2/config.py +++ b/medusa/server/api/v2/config.py @@ -217,6 +217,7 @@ class ConfigHandler(BaseRequestHandler): 'postProcessing.deleteRarContent': BooleanField(app, 'DELRARCONTENTS'), 'postProcessing.unpack': BooleanField(app, 'UNPACK'), 'postProcessing.noDelete': BooleanField(app, 'NO_DELETE'), + 'postProcessing.processIfFileSizeDifferent': BooleanField(app, 'PROCESS_IF_FILE_SIZE_DIFFERENT'), 'postProcessing.postponeIfSyncFiles': BooleanField(app, 'POSTPONE_IF_SYNC_FILES'), 'postProcessing.autoPostprocessorFrequency': IntegerField(app, 'AUTOPOSTPROCESSOR_FREQUENCY'), 'postProcessing.airdateEpisodes': BooleanField(app, 'AIRDATE_EPISODES'), @@ -1127,6 +1128,7 @@ def data_postprocessing(): section_data['naming']['stripYear'] = bool(app.NAMING_STRIP_YEAR) section_data['showDownloadDir'] = app.TV_DOWNLOAD_DIR section_data['processAutomatically'] = bool(app.PROCESS_AUTOMATICALLY) + section_data['processIfFileSizeDifferent'] = bool(app.PROCESS_IF_FILE_SIZE_DIFFERENT) section_data['postponeIfSyncFiles'] = bool(app.POSTPONE_IF_SYNC_FILES) section_data['postponeIfNoSubs'] = bool(app.POSTPONE_IF_NO_SUBS) section_data['renameEpisodes'] = bool(app.RENAME_EPISODES) diff --git a/themes-default/slim/src/components/config-post-processing.vue b/themes-default/slim/src/components/config-post-processing.vue index 6afac331b2..e27cc91310 100644 --- a/themes-default/slim/src/components/config-post-processing.vue +++ b/themes-default/slim/src/components/config-post-processing.vue @@ -86,6 +86,16 @@ +
+ +
+ + If a download is of the same exist quality but file sizes are different, process anyhow. +
+
+