mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
delete failed fix #114
This commit is contained in:
parent
7668b5bed6
commit
4446a47d12
3 changed files with 22 additions and 0 deletions
|
@ -22,6 +22,7 @@ import urllib
|
||||||
import os
|
import os
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
|
|
||||||
import Transcoder
|
import Transcoder
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
|
@ -49,6 +50,14 @@ class AuthURLOpener(urllib.FancyURLopener):
|
||||||
return urllib.FancyURLopener.open(self, url)
|
return urllib.FancyURLopener.open(self, url)
|
||||||
|
|
||||||
|
|
||||||
|
def delete(dirName):
|
||||||
|
Logger.info("Deleting failed files and folder %s", dirName)
|
||||||
|
try:
|
||||||
|
shutil.rmtree(dirName)
|
||||||
|
except e:
|
||||||
|
Logger.error("Unable to delete folder %s due to: %s", dirName, str(e))
|
||||||
|
|
||||||
|
|
||||||
def processEpisode(dirName, nzbName=None, failed=False):
|
def processEpisode(dirName, nzbName=None, failed=False):
|
||||||
|
|
||||||
status = int(failed)
|
status = int(failed)
|
||||||
|
@ -92,11 +101,18 @@ def processEpisode(dirName, nzbName=None, failed=False):
|
||||||
failed_fork = int(config.get("SickBeard", "failed_fork"))
|
failed_fork = int(config.get("SickBeard", "failed_fork"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
failed_fork = 0
|
failed_fork = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config.get("Transcoder", "transcode"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
transcode = 0
|
transcode = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
delete_failed = int(config.get("CouchPotato", "delete_failed"))
|
||||||
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
delete_failed = 0
|
||||||
|
|
||||||
|
|
||||||
process_all_exceptions(nzbName.lower(), dirName)
|
process_all_exceptions(nzbName.lower(), dirName)
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,6 +150,8 @@ def processEpisode(dirName, nzbName=None, failed=False):
|
||||||
Logger.info("The download succeeded. Sending process request to SickBeard")
|
Logger.info("The download succeeded. Sending process request to SickBeard")
|
||||||
else:
|
else:
|
||||||
Logger.info("The download failed. Nothing to process")
|
Logger.info("The download failed. Nothing to process")
|
||||||
|
if delete_failed and not dirName in ['sys.argv[0]','/','']:
|
||||||
|
delete(dirName)
|
||||||
return 0 # Success (as far as this script is concerned)
|
return 0 # Success (as far as this script is concerned)
|
||||||
|
|
||||||
if status == 0 and transcode == 1: # only transcode successful downlaods
|
if status == 0 and transcode == 1: # only transcode successful downlaods
|
||||||
|
@ -163,4 +181,6 @@ def processEpisode(dirName, nzbName=None, failed=False):
|
||||||
result = urlObj.readlines()
|
result = urlObj.readlines()
|
||||||
for line in result:
|
for line in result:
|
||||||
Logger.info("%s", line.rstrip())
|
Logger.info("%s", line.rstrip())
|
||||||
|
if status != 0 and delete_failed and not dirName in ['sys.argv[0]','/','']:
|
||||||
|
delete(dirName)
|
||||||
return 0 # Success
|
return 0 # Success
|
||||||
|
|
|
@ -31,6 +31,7 @@ web_root =
|
||||||
ssl = 0
|
ssl = 0
|
||||||
watch_dir =
|
watch_dir =
|
||||||
failed_fork = 0
|
failed_fork = 0
|
||||||
|
delete_failed = 0
|
||||||
|
|
||||||
|
|
||||||
[HeadPhones]
|
[HeadPhones]
|
||||||
|
|
|
@ -21,6 +21,7 @@ web_root =
|
||||||
ssl = 0
|
ssl = 0
|
||||||
watch_dir = C:\TV\new
|
watch_dir = C:\TV\new
|
||||||
failed_fork = 0
|
failed_fork = 0
|
||||||
|
delete_failed = 0
|
||||||
|
|
||||||
[HeadPhones]
|
[HeadPhones]
|
||||||
hpCategory = music
|
hpCategory = music
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue