Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enable filesize upgrades #7967

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ def initialize(self, console_logging=True):
app.PROCESS_METHOD = check_setting_str(app.CFG, 'General', 'process_method', 'copy' if app.KEEP_PROCESSED_DIR else 'move')
app.DELRARCONTENTS = bool(check_setting_int(app.CFG, 'General', 'del_rar_contents', 0))
app.MOVE_ASSOCIATED_FILES = bool(check_setting_int(app.CFG, 'General', 'move_associated_files', 0))
app.PROCESS_IF_FILE_SIZE_DIFFERENT = bool(check_setting_int(app.CFG, 'General', 'process_if_file_size_different', 0))
app.POSTPONE_IF_SYNC_FILES = bool(check_setting_int(app.CFG, 'General', 'postpone_if_sync_files', 1))
app.POSTPONE_IF_NO_SUBS = bool(check_setting_int(app.CFG, 'General', 'postpone_if_no_subs', 0))
app.SYNC_FILES = check_setting_list(app.CFG, 'General', 'sync_files', app.SYNC_FILES)
Expand Down Expand Up @@ -1563,6 +1564,7 @@ def save_config():
new_config['General']['move_associated_files'] = int(app.MOVE_ASSOCIATED_FILES)
new_config['General']['sync_files'] = app.SYNC_FILES
new_config['General']['postpone_if_sync_files'] = int(app.POSTPONE_IF_SYNC_FILES)
new_config['General']['process_if_file_size_different'] = int(app.PROCESS_IF_FILE_SIZE_DIFFERENT)
new_config['General']['postpone_if_no_subs'] = int(app.POSTPONE_IF_NO_SUBS)
new_config['General']['nfo_rename'] = int(app.NFO_RENAME)
new_config['General']['process_automatically'] = int(app.PROCESS_AUTOMATICALLY)
Expand Down
1 change: 1 addition & 0 deletions medusa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions medusa/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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 app.PROCESS_IF_FILE_SIZE_DIFFERENT and 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:
Expand All @@ -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 app.PROCESS_IF_FILE_SIZE_DIFFERENT and 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'
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions medusa/server/api/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/apiv2/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def config_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)
Expand Down
6 changes: 4 additions & 2 deletions themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
"vue-snotify": "3.2.1",
"vue-template-compiler": "2.6.11",
"vue-truncate-collapsed": "2.1.0",
"vuex": "3.1.3"
"vuex": "3.1.3",
"yarn": "^1.22.4",
"yarn-cli": "^0.5.7"
},
"devDependencies": {
"@babel/core": "7.9.0",
Expand Down Expand Up @@ -99,7 +101,7 @@
"timekeeper": "2.2.0",
"vue-jest": "3.0.5",
"vue-loader": "15.9.1",
"webpack": "4.42.1",
"webpack": "^4.42.1",
"webpack-cli": "3.3.11"
},
"stylelint": {
Expand Down
10 changes: 10 additions & 0 deletions themes-default/slim/src/components/config-post-processing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
</div>
</div>

<div class="form-group">
<label for="process_if_file_size_different" class="col-sm-2 control-label">
<span>Process if file size changes</span>
</label>
<div class="col-sm-10 content">
<toggle-button :width="45" :height="22" id="process_if_file_size_different" name="process_if_file_size_different" v-model="postprocessing.processIfFileSizeDifferent" />
<span>If a download is of the same existing quality but file sizes are different, process anyhow.</span>
</div>
</div>

<div class="form-group">
<label for="sync_files" class="col-sm-2 control-label">
<span>Sync File Extensions</span>
Expand Down