mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
Manual run for sickbeard now gets a list of sub-folders from the outputDirectory and send them one at a time to be processed so that the base folder does not get deleted.
This commit is contained in:
parent
b67372622a
commit
ec5b143a38
2 changed files with 36 additions and 25 deletions
|
@ -26,7 +26,10 @@ class AuthURLOpener(urllib.FancyURLopener):
|
|||
|
||||
def openit(self, url):
|
||||
self.numTries = 0
|
||||
return urllib.FancyURLopener.open(self, url)
|
||||
try:
|
||||
return urllib.FancyURLopener.open(self, url)
|
||||
except:
|
||||
raise IOError("Unable to open URL")
|
||||
|
||||
def delete(dirName):
|
||||
Logger.info("Deleting failed files and folder %s", dirName)
|
||||
|
@ -96,33 +99,13 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent = "manual",
|
|||
except config.NoOptionError:
|
||||
process_method = None
|
||||
|
||||
# configure dirName for manual run
|
||||
try:
|
||||
if dirName == 'Manual Run':
|
||||
delay = 0
|
||||
if watch_dir != "" and (not host in ['localhost', '127.0.0.1']):
|
||||
dirName = watch_dir
|
||||
else:
|
||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
||||
dirName = os.path.join(config().get("Torrent", "outputDirectory"), sbCategory[0])
|
||||
|
||||
# check if path is valid
|
||||
if not os.path.exists(dirName):
|
||||
return 1 # failure
|
||||
except config.NoOptionError:
|
||||
return 1 # failure
|
||||
|
||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
||||
minSampleSize = int(config().get("Extensions", "minSampleSize"))
|
||||
|
||||
if not os.path.isdir(dirName) and os.path.isfile(dirName): # If the input directory is a file, assume single file download and split dir/name.
|
||||
dirName = os.path.split(os.path.normpath(dirName))[0]
|
||||
|
||||
if nzbName:
|
||||
SpecificPath = os.path.join(dirName, str(nzbName))
|
||||
else:
|
||||
SpecificPath = dirName
|
||||
|
||||
SpecificPath = os.path.join(dirName, str(nzbName))
|
||||
cleanName = os.path.splitext(SpecificPath)
|
||||
if cleanName[1] == ".nzb":
|
||||
SpecificPath = cleanName[0]
|
||||
|
@ -212,6 +195,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent = "manual",
|
|||
|
||||
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(params)
|
||||
|
||||
if clientAgent == "manual":delay = 0
|
||||
Logger.info("Waiting for %s seconds to allow SB to process newly extracted files", str(delay))
|
||||
|
||||
time.sleep(delay)
|
||||
|
|
|
@ -407,14 +407,41 @@ else: # only CPS and SB supports this manual run for now.
|
|||
nzbDir, inputName, status, inputCategory, download_id = ('Manual Run', 'Manual Run', 0, cpsCategory[0], '')
|
||||
|
||||
Logger.info("MAIN: Running autoProcessTV as a manual run...")
|
||||
nzbDir, inputName, status, inputCategory = ('Manual Run', None, 0, sbCategory[0])
|
||||
inputCategory = sbCategory[0]
|
||||
|
||||
if inputCategory in cpsCategory:
|
||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
||||
result = autoProcessMovie.process(nzbDir, inputName, status, clientAgent, download_id, inputCategory)
|
||||
elif inputCategory in sbCategory:
|
||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||
result = autoProcessTV.processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
if clientAgent == "manual":
|
||||
section = "SickBeard"
|
||||
try:
|
||||
watch_dir = config().get(section, "watch_dir")
|
||||
except config.NoOptionError:
|
||||
watch_dir = ""
|
||||
try:
|
||||
outputDirectory = os.path.join(config().get("Torrent", "outputDirectory"), sbCategory[0])
|
||||
except config.NoOptionError:
|
||||
outputDirectory = ""
|
||||
|
||||
# set dirName
|
||||
dirNames = None
|
||||
if watch_dir != "":
|
||||
dirNames = [os.path.join(watch_dir, o) for o in os.listdir(watch_dir) if os.path.isdir(os.path.join(watch_dir, o))]
|
||||
elif outputDirectory != "":
|
||||
dirNames = [os.path.join(outputDirectory, o) for o in os.listdir(outputDirectory) if os.path.isdir(os.path.join(outputDirectory, o))]
|
||||
|
||||
for dirName in dirNames:
|
||||
if os.path.exists(dirName):
|
||||
nzbDir = inputName = dirName
|
||||
|
||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||
result = autoProcessTV.processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
if result != 0:
|
||||
break
|
||||
else:
|
||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||
result = autoProcessTV.processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
elif inputCategory in hpCategory:
|
||||
Logger.info("MAIN: Calling HeadPhones to post-process: %s", inputName)
|
||||
result = autoProcessMusic.process(nzbDir, inputName, status, inputCategory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue