Merge branch 'dev' into syno-debug. to test fix for #355

This commit is contained in:
clinton-hall 2014-05-02 12:40:55 +09:30
commit 45883ab238
5 changed files with 31 additions and 8 deletions

View file

@ -125,7 +125,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
for inputFile in inputFiles: for inputFile in inputFiles:
filePath = os.path.dirname(inputFile) filePath = os.path.dirname(inputFile)
fileName, fileExt = os.path.splitext(os.path.basename(inputFile)) fileName, fileExt = os.path.splitext(os.path.basename(inputFile))
fullFileName = os.path.basename(inputFile) if fileExt in nzbtomedia.EXT_REPLACE:
fullFileName = fileName + nzbtomedia.EXT_REPLACE[fileExt]
else:
fullFileName = os.path.basename(inputFile)
targetFile = nzbtomedia.os.path.join(outputDestination, fullFileName) targetFile = nzbtomedia.os.path.join(outputDestination, fullFileName)
if inputCategory in nzbtomedia.NOFLATTEN: if inputCategory in nzbtomedia.NOFLATTEN:

View file

@ -104,6 +104,7 @@ DELUGEPWD = None
EXTCONTAINER = [] EXTCONTAINER = []
COMPRESSEDCONTAINER = [] COMPRESSEDCONTAINER = []
EXT_REPLACE = {}
MEDIACONTAINER = [] MEDIACONTAINER = []
AUDIOCONTAINER = [] AUDIOCONTAINER = []
METACONTAINER = [] METACONTAINER = []
@ -156,7 +157,7 @@ def initialize(section=None):
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \ OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE
if __INITIALIZED__: if __INITIALIZED__:
return False return False
@ -273,6 +274,7 @@ def initialize(section=None):
re.compile('.part\d+.rar$', re.I), re.compile('.part\d+.rar$', re.I),
re.compile('.rar$', re.I)] re.compile('.rar$', re.I)]
COMPRESSEDCONTAINER += [re.compile('%s$' % ext, re.I) for ext in CFG["Extensions"]["compressedExtensions"]] COMPRESSEDCONTAINER += [re.compile('%s$' % ext, re.I) for ext in CFG["Extensions"]["compressedExtensions"]]
EXT_REPLACE = {'.cbr':'.rar', '.cbz':'.zip'} # extensions used for comic books need to be replaced before we can extract.
MEDIACONTAINER = CFG["Extensions"]["mediaExtensions"] MEDIACONTAINER = CFG["Extensions"]["mediaExtensions"]
AUDIOCONTAINER = CFG["Extensions"]["audioExtensions"] AUDIOCONTAINER = CFG["Extensions"]["audioExtensions"]
METACONTAINER = CFG["Extensions"]["metaExtensions"] # .nfo,.sub,.srt METACONTAINER = CFG["Extensions"]["metaExtensions"] # .nfo,.sub,.srt

View file

@ -2,7 +2,7 @@ import os
import time import time
import nzbtomedia import nzbtomedia
import requests import requests
from nzbtomedia.nzbToMediaUtil import convert_to_ascii from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions
from nzbtomedia import logger from nzbtomedia import logger
class autoProcessComics: class autoProcessComics:
@ -29,6 +29,8 @@ class autoProcessComics:
inputName, dirName = convert_to_ascii(inputName, dirName) inputName, dirName = convert_to_ascii(inputName, dirName)
replaceExtensions(dirName)
params = {} params = {}
params['nzb_folder'] = dirName params['nzb_folder'] = dirName
if remote_path: if remote_path:

View file

@ -1,6 +1,7 @@
import copy import copy
import os import os
import requests import requests
import json
import nzbtomedia import nzbtomedia
from nzbtomedia.nzbToMediaAutoFork import autoFork from nzbtomedia.nzbToMediaAutoFork import autoFork
@ -140,9 +141,9 @@ class autoProcessTV:
if section == "SickBeard": if section == "SickBeard":
r = requests.get(url, auth=(username, password), params=fork_params, stream=True, verify=False) r = requests.get(url, auth=(username, password), params=fork_params, stream=True, verify=False)
elif section == "NzbDrone": elif section == "NzbDrone":
params = {"name": "DownloadedEpisodesScan", "path": dirName} data = json.dumps({"name": "DownloadedEpisodesScan", "path": dirName})
headers = {"X-Api-Key": apikey} headers = {"X-Api-Key": apikey}
r = requests.get(url, params=params, headers=headers, stream=True, verify=False) r = requests.post(url, data=data, headers=headers, stream=True, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL: %s" % (url), section) logger.error("Unable to open URL: %s" % (url), section)
return 1 # failure return 1 # failure
@ -151,7 +152,7 @@ class autoProcessTV:
for line in r.iter_lines(): for line in r.iter_lines():
if line: if line:
logger.postprocess("%s" % (line), section) logger.postprocess("%s" % (line), section)
if section == "SickBeard" and "Processing succeeded for" in line: if section == "SickBeard" and "Processing succeeded" in line:
Success = True Success = True
elif section == "NzbDrone" and "stateChangeTime" in line: elif section == "NzbDrone" and "stateChangeTime" in line:
Success = True Success = True

View file

@ -39,6 +39,21 @@ def sanitizeName(name):
return name return name
def replaceExtensions(path):
for dirpath, dirnames, filesnames in os.walk(path):
for filename in filesnames:
name, ext = os.path.splitext(filename)
if ext in nzbtomedia.EXT_REPLACE:
file = os.path.join(dirpath, filename)
target = os.path.join(dirpath, name + nzbtomedia.EXT_REPLACE[ext])
try:
logger.debug("Renaming %s to %s" % (file, target), 'RENAME')
shutil.move(file, target)
except:
logger.error("Could not rename %s to %s" % (file, target), 'RENAME')
else:
continue
def makeDir(path): def makeDir(path):
if not os.path.isdir(path): if not os.path.isdir(path):
try: try:
@ -771,7 +786,7 @@ def backupVersionedFile(old_file, version):
def update_downloadInfoStatus(inputName, status): def update_downloadInfoStatus(inputName, status):
logger.debug("Updating status of our download %s in the DB to %s" % (inputName, status)) logger.db("Updating status of our download %s in the DB to %s" % (inputName, status))
myDB = nzbToMediaDB.DBConnection() myDB = nzbToMediaDB.DBConnection()
myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?", myDB.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?",
@ -779,7 +794,7 @@ def update_downloadInfoStatus(inputName, status):
def get_downloadInfo(inputName, status): def get_downloadInfo(inputName, status):
logger.debug("Getting download info for %s from the DB" % (inputName)) logger.db("Getting download info for %s from the DB" % (inputName))
myDB = nzbToMediaDB.DBConnection() myDB = nzbToMediaDB.DBConnection()
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?", sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?",