mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-23 06:25:22 -07:00
Merge branch 'dev' into syno-debug. to test fix for #355
This commit is contained in:
commit
45883ab238
5 changed files with 31 additions and 8 deletions
|
@ -125,7 +125,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
|||
for inputFile in inputFiles:
|
||||
filePath = os.path.dirname(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)
|
||||
if inputCategory in nzbtomedia.NOFLATTEN:
|
||||
|
|
|
@ -104,6 +104,7 @@ DELUGEPWD = None
|
|||
|
||||
EXTCONTAINER = []
|
||||
COMPRESSEDCONTAINER = []
|
||||
EXT_REPLACE = {}
|
||||
MEDIACONTAINER = []
|
||||
AUDIOCONTAINER = []
|
||||
METACONTAINER = []
|
||||
|
@ -156,7 +157,7 @@ def initialize(section=None):
|
|||
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
|
||||
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, \
|
||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO
|
||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
|
@ -273,6 +274,7 @@ def initialize(section=None):
|
|||
re.compile('.part\d+.rar$', re.I),
|
||||
re.compile('.rar$', re.I)]
|
||||
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"]
|
||||
AUDIOCONTAINER = CFG["Extensions"]["audioExtensions"]
|
||||
METACONTAINER = CFG["Extensions"]["metaExtensions"] # .nfo,.sub,.srt
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
import time
|
||||
import nzbtomedia
|
||||
import requests
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions
|
||||
from nzbtomedia import logger
|
||||
|
||||
class autoProcessComics:
|
||||
|
@ -29,6 +29,8 @@ class autoProcessComics:
|
|||
|
||||
inputName, dirName = convert_to_ascii(inputName, dirName)
|
||||
|
||||
replaceExtensions(dirName)
|
||||
|
||||
params = {}
|
||||
params['nzb_folder'] = dirName
|
||||
if remote_path:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import copy
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
import nzbtomedia
|
||||
|
||||
from nzbtomedia.nzbToMediaAutoFork import autoFork
|
||||
|
@ -140,9 +141,9 @@ class autoProcessTV:
|
|||
if section == "SickBeard":
|
||||
r = requests.get(url, auth=(username, password), params=fork_params, stream=True, verify=False)
|
||||
elif section == "NzbDrone":
|
||||
params = {"name": "DownloadedEpisodesScan", "path": dirName}
|
||||
data = json.dumps({"name": "DownloadedEpisodesScan", "path": dirName})
|
||||
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:
|
||||
logger.error("Unable to open URL: %s" % (url), section)
|
||||
return 1 # failure
|
||||
|
@ -151,7 +152,7 @@ class autoProcessTV:
|
|||
for line in r.iter_lines():
|
||||
if line:
|
||||
logger.postprocess("%s" % (line), section)
|
||||
if section == "SickBeard" and "Processing succeeded for" in line:
|
||||
if section == "SickBeard" and "Processing succeeded" in line:
|
||||
Success = True
|
||||
elif section == "NzbDrone" and "stateChangeTime" in line:
|
||||
Success = True
|
||||
|
|
|
@ -39,6 +39,21 @@ def sanitizeName(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):
|
||||
if not os.path.isdir(path):
|
||||
try:
|
||||
|
@ -771,7 +786,7 @@ def backupVersionedFile(old_file, version):
|
|||
|
||||
|
||||
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.action("UPDATE downloads SET status=?, last_update=? WHERE input_name=?",
|
||||
|
@ -779,7 +794,7 @@ def update_downloadInfoStatus(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()
|
||||
sqlResults = myDB.select("SELECT * FROM downloads WHERE input_name=? AND status=?",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue