diff --git a/autoProcess/autoProcessComics.py b/autoProcess/autoProcessComics.py index 310029bf..0edd1762 100644 --- a/autoProcess/autoProcessComics.py +++ b/autoProcess/autoProcessComics.py @@ -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 diff --git a/autoProcess/autoProcessGames.py b/autoProcess/autoProcessGames.py index 336c4f46..8ff2484a 100644 --- a/autoProcess/autoProcessGames.py +++ b/autoProcess/autoProcessGames.py @@ -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("-") diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index f24aa151..61c8fba6 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -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: diff --git a/autoProcess/autoProcessMusic.py b/autoProcess/autoProcessMusic.py index bc991768..98eee1ed 100644 --- a/autoProcess/autoProcessMusic.py +++ b/autoProcess/autoProcessMusic.py @@ -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: diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index 7c794f42..336a8388 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -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: diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index cf70b2ff..84624fa1 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -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: diff --git a/autoProcess/nzbToMediaUtil.py b/autoProcess/nzbToMediaUtil.py index 72be6e79..046e1553 100644 --- a/autoProcess/nzbToMediaUtil.py +++ b/autoProcess/nzbToMediaUtil.py @@ -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]), '', '', '', '' diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 9d5cc4a0..735a45bd 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -145,6 +145,10 @@ user_script_successCodes = 0 user_script_clean = 1 delay = 120 +[ASCII] +#Set convert =1 if you want to convert any "foreign" characters to ASCII before passing to SB/CP etc. Default is disabled (0). +convert = 0 + # Logging configuration [loggers] keys = root