mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
add option to convert to ASCII. fixes #204
This commit is contained in:
parent
9dae7979e4
commit
ed359e8468
8 changed files with 47 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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("-")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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]), '', '', '', ''
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue