add option to convert to ASCII. fixes #204

This commit is contained in:
clinton-hall 2013-11-25 12:03:54 +10:30
commit ed359e8468
8 changed files with 47 additions and 0 deletions

View file

@ -61,6 +61,8 @@ def processEpisode(dirName, nzbName=None, status=0):
watch_dir = ""
params = {}
nzbName, dirName = converto_to_ascii(nzbName, dirName)
if dirName == "Manual Run" and watch_dir != "":
dirName = watch_dir

View file

@ -44,6 +44,8 @@ def process(dirName, nzbName=None, status=0):
else:
protocol = "http://"
nzbName, dirName = converto_to_ascii(nzbName, dirName)
baseURL = protocol + host + ":" + port + web_root + "/api?api_key=" + apikey + "&mode="
fields = nzbName.split("-")

View file

@ -249,6 +249,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
initial_status, clientAgent, download_id, initial_release_status = get_status(baseURL, movie_id, clientAgent, download_id)
process_all_exceptions(nzbName.lower(), dirName)
nzbName, dirName = converto_to_ascii(nzbName, dirName)
if status == 0:
if transcode == 1:

View file

@ -48,6 +48,8 @@ def process(dirName, nzbName=None, status=0):
if nzbName == "Manual Run":
delay = 0
nzbName, dirName = converto_to_ascii(nzbName, dirName)
baseURL = protocol + host + ":" + port + web_root + "/api?apikey=" + apikey + "&cmd="
if status == 0:

View file

@ -98,6 +98,7 @@ def processEpisode(dirName, nzbName=None, failed=False):
if not fork in SICKBEARD_TORRENT:
process_all_exceptions(nzbName.lower(), dirName)
nzbName, dirName = converto_to_ascii(nzbName, dirName)
if nzbName != "Manual Run" and not fork in SICKBEARD_TORRENT:
# Now check if movie files exist in destination:

View file

@ -165,6 +165,16 @@ def migrate():
option, value = item
confignew.set(section, option, value)
section = "ASCII"
original = []
try:
original = configold.items(section)
except:
pass
for item in original:
option, value = item
confignew.set(section, option, value)
section = "loggers"
original = []
try:

View file

@ -314,6 +314,31 @@ def WakeUp():
else:
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
def converto_to_ascii(nzbName, dirName):
config = ConfigParser.ConfigParser()
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
if not os.path.isfile(configFilename):
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
return nzbName, dirName
config.read(configFilename)
ascii_convert = int(config.get("ASCII", "convert"))
if ascii_convert == 0: # just return if we don't need to wake anything.
return nzbName, dirName
nzbName2 = str(nzbName.decode('ascii', 'replace').replace(u'\ufffd', '_'))
dirName2 = str(dirName.decode('ascii', 'replace').replace(u'\ufffd', '_'))
if dirName != nzbName2:
Logger.info("Renaming directory:%s to: %s.", dirName, nzbName2)
shutil.move(dirName, nzbName2)
for dirpath, dirnames, filesnames in os.walk(dirName2):
for filename in filesnames:
filename2 = str(filename.decode('ascii', 'replace').replace(u'\ufffd', '_'))
if filename != filename2:
Logger.info("Renaming file:%s to: %s.", filename, filename2)
shutil.move(filename, filename2)
nzbName = nzbName2
dirName = nzbName2
return nzbName, dirName
def parse_other(args):
return os.path.normpath(sys.argv[1]), '', '', '', ''