diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 9b2fa5aa3b82a4134bd8eec9f36c29ec5e5e8640..de35e84fb695967d506eeeb33d9c20c788c4b3f2 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -148,7 +148,7 @@ class PostProcessor(object): logger.DEBUG) return PostProcessor.DOESNT_EXIST - def list_associated_files(self, file_path, base_name_only=False, subtitles_only=False, subfolders=False): + def list_associated_files(self, file_path, base_name_only=False, subtitles_only=False, subfolders=False): # pylint: disable=unused-argument """ For a given file path searches for files with the same name but different extension and returns their absolute paths @@ -970,8 +970,10 @@ class PostProcessor(object): if self.is_proper and new_ep_quality == old_ep_quality: self._log(u"New file is a proper/repack, marking it safe to replace") else: - self._log(u"File exists and new file is the same or lower quality than existing, marking it unsafe to replace") - return False + _, preferred_qualities = common.Quality.splitQuality(int(show.quality)) + if new_ep_quality not in preferred_qualities: + self._log(u"File exists and new file quality is not in a preferred quality list, marking it unsafe to replace") + return False # Check if the processed file season is already in our indexer. If not, the file is most probably mislabled/fake and will be skipped # Only proceed if the file season is > 0 @@ -993,7 +995,7 @@ class PostProcessor(object): # try to find out if we have enough space to perform the copy or move action. if not helpers.isFileLocked(self.file_path, False): - if not verify_freespace(self.file_path, ep_obj.show._location, [ep_obj] + ep_obj.relatedEps): + if not verify_freespace(self.file_path, ep_obj.show._location, [ep_obj] + ep_obj.relatedEps): # pylint: disable=protected-access self._log("Not enough space to continue PP, exiting", logger.WARNING) return False else: @@ -1006,7 +1008,7 @@ class PostProcessor(object): # clean up any left over folders if cur_ep.location: - helpers.delete_empty_folders(ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location) + helpers.delete_empty_folders(ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location) # pylint: disable=protected-access except (OSError, IOError): raise EpisodePostProcessingFailedException("Unable to delete the existing files") @@ -1015,16 +1017,16 @@ class PostProcessor(object): # curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality) # if the show directory doesn't exist then make it if allowed - if not ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS: + if not ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS: # pylint: disable=protected-access self._log(u"Show directory doesn't exist, creating it", logger.DEBUG) try: - ek(os.mkdir, ep_obj.show._location) - helpers.chmodAsParent(ep_obj.show._location) + ek(os.mkdir, ep_obj.show._location) # pylint: disable=protected-access + helpers.chmodAsParent(ep_obj.show._location) # pylint: disable=protected-access # do the library update for synoindex - notifiers.synoindex_notifier.addFolder(ep_obj.show._location) + notifiers.synoindex_notifier.addFolder(ep_obj.show._location) # pylint: disable=protected-access except (OSError, IOError): - raise EpisodePostProcessingFailedException("Unable to create the show directory: " + ep_obj.show._location) + raise EpisodePostProcessingFailedException("Unable to create the show directory: " + ep_obj.show._location) # pylint: disable=protected-access # get metadata for the show (but not episode because it hasn't been fully processed) ep_obj.show.writeMetadata(True) @@ -1162,7 +1164,7 @@ class PostProcessor(object): ep_obj.createMetaFiles() except Exception: logger.log(u"Could not create/update meta files. Continuing with postProcessing...") - + # log it to history history.logDownload(ep_obj, self.file_path, new_ep_quality, self.release_group, new_ep_version) @@ -1170,7 +1172,7 @@ class PostProcessor(object): # If any notification fails, don't stop postProcessor try: # send notifications - notifiers.notify_download(ep_obj._format_pattern('%SN - %Sx%0E - %EN - %QN')) + notifiers.notify_download(ep_obj._format_pattern('%SN - %Sx%0E - %EN - %QN')) # pylint: disable=protected-access # do the library update for KODI notifiers.kodi_notifier.update_library(ep_obj.show.name)