1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-25 01:01:47 +00:00

FIX: post-processing failing due to inability to find nzb in db to match (#136)

This commit is contained in:
evilhero 2013-01-07 23:24:00 -05:00
parent c6d2d296ae
commit a853274506
3 changed files with 27 additions and 32 deletions

View file

@ -131,34 +131,26 @@ class PostProcessor(object):
myDB = db.DBConnection() myDB = db.DBConnection()
nzbname = self.nzb_name nzbname = self.nzb_name
#remove extensions from nzb_name if they somehow got through (Experimental most likely)
extensions = ('.cbr', '.cbz')
if nzbname.lower().endswith(extensions):
fd, ext = os.path.splitext(nzbname)
self._log("Removed extension from nzb: " + ext, logger.DEBUG)
nzbname = re.sub(str(ext), '', str(nzbname))
#replace spaces
nzbname = re.sub(' ', '.', str(nzbname))
self._log("nzbname: " + str(nzbname), logger.DEBUG)
nzbiss = myDB.action("SELECT * from nzblog WHERE nzbname=?", [nzbname]).fetchone() nzbiss = myDB.action("SELECT * from nzblog WHERE nzbname=?", [nzbname]).fetchone()
if nzbiss is None: if nzbiss is None:
self._log("Failure - could not initially locate nzbfile in my database to rename.", logger.DEBUG) self._log("Failure - could not initially locate nzbfile in my database to rename.", logger.DEBUG)
#decimals need to be accounted for.... # if failed on spaces, change it all to decimals and try again.
if str(sabrepd) == '0': nzbname = re.sub('_', '.', str(nzbname))
#Replace decimals is enabled so decimlas should already be passed through converted. self._log("trying again with this nzbname: " + str(nzbname), logger.DEBUG)
logger.info("SABnzbd setting: Replace Decimals is disabled.")
elif str(sabrepd) == '1':
#Replace decimals is enabled.
#By default SAB will pass back the value with decimals replaced with a ' ' or a '_'
logger.info("SABnzbd setting: Replace Decimals is enabled.")
self._log("I'm going to try to rejig the nzbname passed from SAB accounting for decmials to see if I can find it.")
nzbname = re.sub('[\.]', '_', str(nzbname))
#spaces need to be accounted for
if str(sabreps) == '1':
#Replace spaces is enabled so spaces should already be passed through converted.
logger.info("SABnzbd setting: Replace spaces is enabled.")
elif str(sabreps) == '0':
#Replace space is disabled.
#By default SAB will pass back the value with spaces replaced with a '+'
logger.info("SABnzbd setting: Replace spaces is disabled.")
self._log("I'm going to try to rejig the nzbname passed from SAB accouting for spaces to see if I can find it.")
nzbname = re.sub(' ', '_', str(nzbname))
#let's remove the - cause it will cause problems at this point...
nzbname = re.sub('[\-]', '_', str(nzbname))
logger.fdebug("trying again with this nzbname: " + str(nzbname))
nzbiss = myDB.action("SELECT * from nzblog WHERE nzbname=?", [nzbname]).fetchone() nzbiss = myDB.action("SELECT * from nzblog WHERE nzbname=?", [nzbname]).fetchone()
if nzbiss is None: if nzbiss is None:
logger.error(u"Unable to locate downloaded file to rename. PostProcessing aborted.") logger.error(u"Unable to locate downloaded file to rename. PostProcessing aborted.")
@ -249,8 +241,6 @@ class PostProcessor(object):
'$Year': issueyear '$Year': issueyear
} }
extensions = ('.cbr', '.cbz')
for root, dirnames, filenames in os.walk(self.nzb_folder): for root, dirnames, filenames in os.walk(self.nzb_folder):
for filename in filenames: for filename in filenames:
if filename.lower().endswith(extensions): if filename.lower().endswith(extensions):

View file

@ -577,11 +577,15 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
logger.fdebug("link to retrieve via api:" + str(linkapi)) logger.fdebug("link to retrieve via api:" + str(linkapi))
#when the series contains a '-' or the issue a decimal it can't convert #let's change all space to decimals for simplicity
#if SAB's settings differ on how it handles spaces / decimals. nzbname = re.sub(" ", ".", str(entry['title']))
#let's attempt to adjust by removing the - and .
nzbname = re.sub(" ", "_", str(entry['title'])) extensions = ('.cbr', '.cbz')
nzbname = re.sub('[\.\-]', '_', str(nzbname))
if nzbname.lower().endswith(extensions):
fd, ext = os.path.splitext(nzbname)
logger.fdebug("Removed extension from nzb: " + ext)
nzbname = re.sub(str(ext), '', str(nzbname))
logger.fdebug("nzbname used for post-processing:" + str(nzbname)) logger.fdebug("nzbname used for post-processing:" + str(nzbname))

View file

@ -262,7 +262,8 @@ def forceRescan(ComicID):
if "(c2c)" in fcnew[som]: if "(c2c)" in fcnew[som]:
fcnew[som] = fcnew[som].replace("(c2c)", " ") fcnew[som] = fcnew[som].replace("(c2c)", " ")
get_issue = shlex.split(str(fcnew[som])) get_issue = shlex.split(str(fcnew[som]))
fcnew[som] = get_issue[0] if fcnew[som] != " ":
fcnew[som] = get_issue[0]
if '.' in fcnew[som]: if '.' in fcnew[som]:
logger.fdebug("decimal detected...adjusting.") logger.fdebug("decimal detected...adjusting.")
try: try: