Skip to content

Commit c4534cc

Browse files
author
Patrick Vos
committed
Remove automatic replacing with proper in name not in status
Safer since processer sorts biggest first, potential risc of replacing with smaller stuff (sample) only because name has proper in it. + Add force replace manual post processing
1 parent feb766b commit c4534cc

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

data/interfaces/default/home_postprocess.tmpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import sickbeard
2-
#set global $title="Post Processing"
2+
#set global $title="Manual Post-Processing"
33

44
#set global $sbPath="../.."
55

@@ -8,7 +8,12 @@
88
#include $os.path.join($sickbeard.PROG_DIR, "data/interfaces/default/inc_top.tmpl")
99

1010
<form name="processForm" method="post" action="processEpisode">
11-
Enter the folder containing the episode: <input type="text" name="dir" id="episodeDir" #if $sickbeard.TV_DOWNLOAD_DIR then "value=" + $sickbeard.TV_DOWNLOAD_DIR else ""# size="50" /><input type="hidden" name="method" value="Manual"> <input type="submit" class="btn" value="Process" />
11+
Enter the folder containing the episode: <input type="text" name="dir" id="episodeDir" #if $sickbeard.TV_DOWNLOAD_DIR then "value=\"" + $sickbeard.TV_DOWNLOAD_DIR + "\"" else ""# size="50" />
12+
<input type="hidden" name="method" value="Manual"> <input type="submit" class="btn" value="Process" />
13+
<br /><br />
14+
Force replace existing episodes:&nbsp;<input type="checkbox" name="force_replace" /><br />
15+
<b>Overwrite</b> existing episode, ignoring status downloaded (quality)<br />
16+
1217
</form>
1318
<br />
1419

sickbeard/postProcessor.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PostProcessor(object):
5858
FOLDER_NAME = 2
5959
FILE_NAME = 3
6060

61-
def __init__(self, file_path, nzb_name=None):
61+
def __init__(self, file_path, nzb_name=None, pp_options={}):
6262
"""
6363
Creates a new post processor with the given file path and optionally an NZB name.
6464
@@ -80,6 +80,8 @@ def __init__(self, file_path, nzb_name=None):
8080
# name of the NZB that resulted in this folder
8181
self.nzb_name = nzb_name
8282

83+
self.force_replace = pp_options.get('force_replace', False)
84+
8385
self.in_history = False
8486
self.release_group = None
8587
self.is_proper = False
@@ -683,9 +685,9 @@ def _safe_replace(self, ep_obj, new_ep_quality):
683685

684686
# Status downloaded. Quality/ size checks
685687

686-
# if the file processed appears to be a PROPER/REPACK then it's safe
687-
if self.is_proper and new_ep_quality >= old_ep_quality and new_ep_quality != common.Quality.UNKNOWN:
688-
self._log(u"Existing episode status is not snatched_proper, but new file appears to be a proper, marking it safe to replace", logger.DEBUG)
688+
# if manual post process option is set to force_replace then it's safe
689+
if self.force_replace:
690+
self._log(u"Processed episode is set to force replace existing episode, marking it safe to replace", logger.DEBUG)
689691
return True
690692

691693
# if the file processed is higher quality than the existing episode then it's safe

sickbeard/processTV.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def logHelper(logMessage, logLevel=logger.MESSAGE):
6767
return logMessage + u"\n"
6868

6969

70-
def processDir(dirName, nzbName=None, method=None, recurse=False):
70+
def processDir(dirName, nzbName=None, method=None, recurse=False, pp_options={}):
7171
"""
7272
Scans through the files in dirName and processes whatever media files it finds
7373
@@ -144,7 +144,7 @@ def processDir(dirName, nzbName=None, method=None, recurse=False):
144144
returnStr += logHelper(u"Ignoring hidden folder: " + cur_folder, logger.DEBUG)
145145
else:
146146
returnStr += logHelper(u"Recursively processing a folder: " + cur_folder, logger.DEBUG)
147-
returnStr += processDir(cur_folder, nzbName=parent_nzbName, recurse=True, method=method)
147+
returnStr += processDir(cur_folder, nzbName=parent_nzbName, recurse=True, method=method, pp_options=pp_options)
148148

149149
remainingFolders = filter(lambda x: ek.ek(os.path.isdir, ek.ek(os.path.join, dirName, x)), fileList)
150150

@@ -182,7 +182,7 @@ def processDir(dirName, nzbName=None, method=None, recurse=False):
182182

183183
try:
184184
returnStr += u"\n"
185-
processor = postProcessor.PostProcessor(cur_video_file_path, nzbName)
185+
processor = postProcessor.PostProcessor(cur_video_file_path, nzb_name=nzbName, pp_options=pp_options)
186186
process_result = processor.process()
187187
process_fail_message = ""
188188

sickbeard/webserve.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,18 @@ def index(self):
13471347
return _munge(t)
13481348

13491349
@cherrypy.expose
1350-
def processEpisode(self, dir=None, nzbName=None, method=None, jobName=None, quiet=None):
1350+
def processEpisode(self, dir=None, nzbName=None, method=None, jobName=None, quiet=None, *args, **kwargs):
13511351

13521352
if not dir:
13531353
redirect("/home/postprocess/")
13541354
else:
1355-
result = processTV.processDir(dir, nzbName, method=method)
1355+
pp_options = {}
1356+
for key, value in kwargs.iteritems():
1357+
if value == 'on':
1358+
value = True
1359+
pp_options[key] = value
1360+
1361+
result = processTV.processDir(dir, nzbName, method=method, pp_options=pp_options)
13561362
if quiet != None and int(quiet) == 1:
13571363
return result
13581364

0 commit comments

Comments
 (0)