Private GIT

Skip to content
Snippets Groups Projects
Commit 5d8913c8 authored by miigotu's avatar miigotu
Browse files

Merge pull request #582 from SickRage/pp-fixes

Allow replacing a higher quality with a lower quality if it is in you…
parents 814697cc d451077d
Branches
Tags
No related merge requests found
...@@ -148,7 +148,7 @@ class PostProcessor(object): ...@@ -148,7 +148,7 @@ class PostProcessor(object):
logger.DEBUG) logger.DEBUG)
return PostProcessor.DOESNT_EXIST 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 For a given file path searches for files with the same name but different extension and returns their absolute paths
...@@ -970,7 +970,9 @@ class PostProcessor(object): ...@@ -970,7 +970,9 @@ class PostProcessor(object):
if self.is_proper and new_ep_quality == old_ep_quality: 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") self._log(u"New file is a proper/repack, marking it safe to replace")
else: else:
self._log(u"File exists and new file is the same or lower quality than existing, marking it unsafe to replace") _, 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 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 # Check if the processed file season is already in our indexer. If not, the file is most probably mislabled/fake and will be skipped
...@@ -993,7 +995,7 @@ class PostProcessor(object): ...@@ -993,7 +995,7 @@ class PostProcessor(object):
# try to find out if we have enough space to perform the copy or move action. # 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 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) self._log("Not enough space to continue PP, exiting", logger.WARNING)
return False return False
else: else:
...@@ -1006,7 +1008,7 @@ class PostProcessor(object): ...@@ -1006,7 +1008,7 @@ class PostProcessor(object):
# clean up any left over folders # clean up any left over folders
if cur_ep.location: 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): except (OSError, IOError):
raise EpisodePostProcessingFailedException("Unable to delete the existing files") raise EpisodePostProcessingFailedException("Unable to delete the existing files")
...@@ -1015,16 +1017,16 @@ class PostProcessor(object): ...@@ -1015,16 +1017,16 @@ class PostProcessor(object):
# curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality) # curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# if the show directory doesn't exist then make it if allowed # 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) self._log(u"Show directory doesn't exist, creating it", logger.DEBUG)
try: try:
ek(os.mkdir, ep_obj.show._location) ek(os.mkdir, ep_obj.show._location) # pylint: disable=protected-access
helpers.chmodAsParent(ep_obj.show._location) helpers.chmodAsParent(ep_obj.show._location) # pylint: disable=protected-access
# do the library update for synoindex # 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): 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) # get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True) ep_obj.show.writeMetadata(True)
...@@ -1170,7 +1172,7 @@ class PostProcessor(object): ...@@ -1170,7 +1172,7 @@ class PostProcessor(object):
# If any notification fails, don't stop postProcessor # If any notification fails, don't stop postProcessor
try: try:
# send notifications # 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 # do the library update for KODI
notifiers.kodi_notifier.update_library(ep_obj.show.name) notifiers.kodi_notifier.update_library(ep_obj.show.name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment