mirror of
https://github.com/evilhero/mylar
synced 2024-12-25 01:01:47 +00:00
FIX:(#1411) When arc issue searching using 32p, would cause an error in regards to publisher not being present, FIX:(#1415) Fixed error with story arcs and searching when the year isn't specified, FIX: Copy/Move will during post-processing will now cleanup cache files properly, FIX:(#1413)(#1416) Fix for invalid reference when updating Story Arc settings.FIX: Added issue exception for issue 112/113, FIX: When story arc issue did not have an issue name present, would error, FIX: multiple destination dirs won't be scanned if the dir(s) don't exist
This commit is contained in:
parent
9ca958f4b7
commit
b437d7450a
7 changed files with 97 additions and 88 deletions
|
@ -36,7 +36,7 @@
|
|||
|
||||
<table class="configtable">
|
||||
<tr>
|
||||
<form action="readOptions" id="chkoptions" method="GET">
|
||||
<form action="arcOptions" id="chkoptions" method="GET">
|
||||
<fieldset>
|
||||
<div class="row checkbox left clearfix">
|
||||
%if mylar.STORYARCDIR:
|
||||
|
|
|
@ -190,6 +190,54 @@ class PostProcessor(object):
|
|||
logger.warn('[DUPLICATE-CLEANUP] Successfully moved ' + path_to_move + ' ... to ... ' + os.path.join(mylar.DUPLICATE_DUMP, file_to_move))
|
||||
return True
|
||||
|
||||
def tidyup(self, odir=None, del_nzbdir = False):
|
||||
# del_nzbdir will remove the original directory location. Must be set to False for manual pp or else will delete manual dir that's provided (if empty).
|
||||
# move = cleanup/delete original location (self.nzb_folder) AND cache location (odir) if metatagging is enabled.
|
||||
# copy = cleanup/delete cache location (odir) only if enabled.
|
||||
#tidyup old path
|
||||
try:
|
||||
logger.fdebug('File Option: ' + mylar.FILE_OPTS + '[META-ENABLED: ' + str(mylar.ENABLE_META) + ']')
|
||||
logger.fdebug('odir: ' + odir + '[self.nzb_folder: ' + self.nzb_folder + ']')
|
||||
#make sure we don't delete the directory passed via manual-pp and ajust for trailling slashes or not
|
||||
if self.nzb_folder.endswith('/') or self.nzb_folder.endswith('\\'):
|
||||
tmp_folder = self.nzb_folder[:-1]
|
||||
else:
|
||||
tmp_folder = self.nzb_folder
|
||||
|
||||
if os.path.isdir(odir) and odir != tmp_folder:
|
||||
# check to see if the directory is empty or not.
|
||||
if mylar.FILE_OPTS == 'move' and del_nzbdir is True:
|
||||
if not os.listdir(tmp_folder):
|
||||
logger.fdebug(self.module + ' Tidying up. Deleting original folder location : ' + tmp_folder)
|
||||
shutil.rmtree(tmp_folder)
|
||||
self._log("Removed temporary directory : " + tmp_folder)
|
||||
else:
|
||||
self._log('Failed to remove temporary directory: ' + tmp_folder)
|
||||
raise OSError(self.module + ' ' + tmp_folder + ' not empty. Skipping removal of directory - this will either be caught in further post-processing or it will have to be manually deleted.')
|
||||
|
||||
if mylar.ENABLE_META:
|
||||
#Regardless of the copy/move operation, we need to delete the files from within the cache directory, then remove the cache directory itself for the given issue.
|
||||
#sometimes during a meta, it retains the cbr as well after conversion depending on settings. Make sure to delete too thus the 'walk'.
|
||||
for filename in os.listdir(odir):
|
||||
filepath = os.path.join(odir, filename)
|
||||
try:
|
||||
os.remove(filepath)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if not os.listdir(odir):
|
||||
logger.fdebug(self.module + ' Tidying up. Deleting temporary cache directory : ' + odir)
|
||||
shutil.rmtree(odir)
|
||||
self._log("Removed temporary directory : " + odir)
|
||||
else:
|
||||
self._log('Failed to remove temporary directory: ' + odir)
|
||||
raise OSError(self.module + ' ' + odir + ' not empty. Skipping removal of temporary cache directory - this will either be caught in further post-processing or have to be manually deleted.')
|
||||
|
||||
except (OSError, IOError):
|
||||
logger.fdebug(self.module + ' Failed to remove directory - Processing will continue, but manual removal is necessary')
|
||||
self._log('Failed to remove temporary directory')
|
||||
|
||||
|
||||
def Process(self):
|
||||
module = self.module
|
||||
self._log("nzb name: " + self.nzb_name)
|
||||
|
@ -779,23 +827,8 @@ class PostProcessor(object):
|
|||
return
|
||||
|
||||
#tidyup old path
|
||||
if mylar.FILE_OPTS == 'move':
|
||||
try:
|
||||
#make sure we don't delete the directory passed via manual-pp and ajust for trailling slashes or not
|
||||
if self.nzb_folder.endswith('/') or self.nzb_folder.endswith('\\'):
|
||||
tmp_folder = self.nzb_folder[:-1]
|
||||
else:
|
||||
tmp_folder = self.nzb_folder
|
||||
|
||||
if os.path.isdir(src_location) and src_location != tmp_folder:
|
||||
if not os.listdir(src_location):
|
||||
shutil.rmtree(src_location)
|
||||
logger.debug(module + ' Removed temporary directory : ' + src_location)
|
||||
self._log("Removed temporary directory : " + src_location)
|
||||
except (OSError, IOError):
|
||||
self._log('Failed to remove temporary directory: ' + src_location)
|
||||
logger.debug(module + ' Failed to remove temporary directory [' + src_location + '] - check directory and manually re-run.')
|
||||
return
|
||||
if any([mylar.FILE_OPTS == 'move', mylar.FILE_OPTS == 'copy']):
|
||||
self.tidyup(src_location, True)
|
||||
|
||||
#delete entry from nzblog table
|
||||
#if it was downloaded via mylar from the storyarc section, it will have an 'S' in the nzblog
|
||||
|
@ -1046,27 +1079,8 @@ class PostProcessor(object):
|
|||
return
|
||||
|
||||
#tidyup old path
|
||||
if mylar.FILE_OPTS == 'move':
|
||||
try:
|
||||
#make sure we don't delete the directory passed via manual-pp and ajust for trailling slashes or not
|
||||
if self.nzb_folder.endswith('/') or self.nzb_folder.endswith('\\'):
|
||||
tmp_folder = self.nzb_folder[:-1]
|
||||
else:
|
||||
tmp_folder = self.nzb_folder
|
||||
|
||||
if os.path.isdir(src_location) and odir != tmp_folder:
|
||||
if not os.listdir(src_location):
|
||||
shutil.rmtree(src_location)
|
||||
logger.debug(module + ' Removed temporary directory : ' + src_location)
|
||||
self._log("Removed temporary directory : " + src_location)
|
||||
if not os.listdir(self.nzb_folder):
|
||||
shutil.rmtree(self.nzb_folder)
|
||||
logger.debug(module + ' Removed temporary directory : ' + self.nzb_folder)
|
||||
self._log("Removed temporary directory : " + self.nzb_folder)
|
||||
except (OSError, IOError):
|
||||
self._log("Failed to remove temporary directory.")
|
||||
logger.debug(module + ' Failed to remove temporary directory - check directory and manually re-run.')
|
||||
return
|
||||
if any([mylar.FILE_OPTS == 'move', mylar.FILE_OPTS == 'copy']):
|
||||
self.tidyup(src_location, True)
|
||||
|
||||
#delete entry from nzblog table
|
||||
myDB.action('DELETE from nzblog WHERE issueid=?', [issueid])
|
||||
|
@ -1717,19 +1731,9 @@ class PostProcessor(object):
|
|||
return self.queue.put(self.valreturn)
|
||||
|
||||
#tidyup old path
|
||||
if mylar.FILE_OPTS == 'move':
|
||||
try:
|
||||
shutil.rmtree(self.nzb_folder)
|
||||
except (OSError, IOError):
|
||||
self._log("Failed to remove temporary directory - check directory and manually re-run.")
|
||||
self._log("Post-Processing ABORTED.")
|
||||
logger.warn(module + ' Failed to remove temporary directory : ' + self.nzb_folder)
|
||||
logger.warn(module + ' Post-Processing ABORTED')
|
||||
self.valreturn.append({"self.log": self.log,
|
||||
"mode": 'stop'})
|
||||
return self.queue.put(self.valreturn)
|
||||
self._log("Removed temporary directory : " + self.nzb_folder)
|
||||
logger.fdebug(module + ' Removed temporary directory : ' + self.nzb_folder)
|
||||
if any([mylar.FILE_OPTS == 'move', mylar.FILE_OPTS == 'copy']):
|
||||
self.tidyup(del_nzbdir=True)
|
||||
|
||||
else:
|
||||
#downtype = for use with updater on history table to set status to 'Post-Processed'
|
||||
downtype = 'PP'
|
||||
|
@ -1756,25 +1760,8 @@ class PostProcessor(object):
|
|||
return self.queue.put(self.valreturn)
|
||||
logger.info(module + ' ' + mylar.FILE_OPTS + ' successful to : ' + dst)
|
||||
|
||||
if mylar.FILE_OPTS == 'move':
|
||||
#tidyup old path
|
||||
try:
|
||||
#make sure we don't delete the directory passed via manual-pp and ajust for trailling slashes or not
|
||||
if self.nzb_folder.endswith('/') or self.nzb_folder.endswith('\\'):
|
||||
tmp_folder = self.nzb_folder[:-1]
|
||||
else:
|
||||
tmp_folder = self.nzb_folder
|
||||
if os.path.isdir(odir) and odir != tmp_folder:
|
||||
# check to see if the directory is empty or not.
|
||||
if not os.listdir(odir):
|
||||
logger.fdebug(module + ' Tidying up. Deleting folder : ' + odir)
|
||||
shutil.rmtree(odir)
|
||||
else:
|
||||
raise OSError(module + ' ' + odir + ' not empty. Skipping removal of directory - this will either be caught in further post-processing or it will have to be removed manually.')
|
||||
else:
|
||||
raise OSError(module + ' ' + odir + ' unable to remove at this time.')
|
||||
except (OSError, IOError):
|
||||
logger.fdebug(module + ' Failed to remove temporary directory (' + odir + ') - Processing will continue, but manual removal is necessary')
|
||||
if any([mylar.FILE_OPTS == 'move', mylar.FILE_OPTS == 'copy']):
|
||||
self.tidyup(odir, False)
|
||||
|
||||
#Hopefully set permissions on downloaded file
|
||||
if mylar.OS_DETECT != 'windows':
|
||||
|
|
|
@ -1022,18 +1022,23 @@ def issuedigits(issnum):
|
|||
int_issnum = ord(tstord.lower())
|
||||
else:
|
||||
while (a < len(tstord)):
|
||||
try:
|
||||
ordtot += ord(tstord[a].lower()) #lower-case the letters for simplicty
|
||||
except ValueError:
|
||||
break
|
||||
ordtot += ord(tstord[a].lower()) #lower-case the letters for simplicty
|
||||
a+=1
|
||||
int_issnum = (int(issno) * 1000) + ordtot
|
||||
elif invchk == "true":
|
||||
logger.fdebug('this does not have an issue # that I can parse properly.')
|
||||
int_issnum = 999999999999999
|
||||
return 999999999999999
|
||||
else:
|
||||
logger.error(str(issnum) + 'this has an alpha-numeric in the issue # which I cannot account for.')
|
||||
int_issnum = 999999999999999
|
||||
if issnum == '9-5':
|
||||
issnum = u'9\xbd'
|
||||
logger.fdebug('issue: 9-5 is an invalid entry. Correcting to : ' + issnum)
|
||||
int_issnum = (9 * 1000) + (.5 * 1000)
|
||||
elif issnum == '112/113':
|
||||
int_issnum = (112 * 1000) + (.5 * 1000)
|
||||
else:
|
||||
logger.error(issnum + ' this has an alpha-numeric in the issue # which I cannot account for.')
|
||||
return 999999999999999
|
||||
|
||||
return int_issnum
|
||||
|
||||
|
||||
|
@ -1691,7 +1696,7 @@ def IssueDetails(filelocation, IssueID=None):
|
|||
|
||||
return issuedetails
|
||||
|
||||
def get_issue_title(IssueID=None, ComicID=None, IssueNumber=None):
|
||||
def get_issue_title(IssueID=None, ComicID=None, IssueNumber=None, IssueArcID=None):
|
||||
import db, logger
|
||||
myDB = db.DBConnection()
|
||||
if IssueID:
|
||||
|
@ -1706,8 +1711,14 @@ def get_issue_title(IssueID=None, ComicID=None, IssueNumber=None):
|
|||
if issue is None:
|
||||
issue = myDB.selectone('SELECT * FROM annuals WHERE IssueID=?', [IssueID]).fetchone()
|
||||
if issue is None:
|
||||
logger.fdebug('Unable to locate given IssueID within the db. Assuming Issue Title is None.')
|
||||
return None
|
||||
if IssueArcID:
|
||||
issue = myDB.selectone('SELECT * FROM readlist WHERE IssueArcID=?', [IssueArcID]).fetchone()
|
||||
if issue is None:
|
||||
logger.fdebug('Unable to locate given IssueID within the db. Assuming Issue Title is None.')
|
||||
return None
|
||||
else:
|
||||
logger.fdebug('Unable to locate given IssueID within the db. Assuming Issue Title is None.')
|
||||
return None
|
||||
|
||||
return issue['IssueName']
|
||||
|
||||
|
|
|
@ -1346,6 +1346,8 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
|
|||
issnum = u'9\xbd'
|
||||
logger.fdebug('issue: 9-5 is an invalid entry. Correcting to : ' + issnum)
|
||||
int_issnum = (9 * 1000) + (.5 * 1000)
|
||||
elif issnum == '112/113':
|
||||
int_issnum = (112 * 1000) + (.5 * 1000)
|
||||
else:
|
||||
logger.error(issnum + ' this has an alpha-numeric in the issue # which I cannot account for.')
|
||||
return
|
||||
|
|
|
@ -56,7 +56,12 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueD
|
|||
if Publisher == 'IDW Publishing':
|
||||
Publisher = 'IDW'
|
||||
logger.fdebug('Publisher is : ' + Publisher)
|
||||
issuetitle = helpers.get_issue_title(IssueID)
|
||||
|
||||
if IssueArcID and not IssueID:
|
||||
issuetitle = helpers.get_issue_title(IssueArcID)
|
||||
else:
|
||||
issuetitle = helpers.get_issue_title(IssueID)
|
||||
|
||||
if issuetitle:
|
||||
logger.info('Issue Title given as : ' + issuetitle)
|
||||
else:
|
||||
|
@ -1934,7 +1939,7 @@ def searcher(nzbprov, nzbname, comicinfo, link, IssueID, ComicID, tmpprov, direc
|
|||
#one-off information
|
||||
logger.fdebug("ComicName: " + ComicName)
|
||||
logger.fdebug("Issue: " + str(IssueNumber))
|
||||
logger.fdebug("Year: " + str(ComicYear))
|
||||
logger.fdebug("Year: " + str(comyear))
|
||||
logger.fdebug("IssueDate:" + str(IssueDate))
|
||||
logger.info(u"Found " + ComicName + " (" + str(comyear) + ") issue: " + IssueNumber + " using " + str(tmpprov))
|
||||
|
||||
|
|
|
@ -808,7 +808,7 @@ def forceRescan(ComicID, archive=None, module=None):
|
|||
comiccnt = int(tmpval['comiccount'])
|
||||
logger.fdebug(module + 'comiccnt is:' + str(comiccnt))
|
||||
fca.append(tmpval)
|
||||
if mylar.MULTIPLE_DEST_DIRS is not None and mylar.MULTIPLE_DEST_DIRS != 'None' and os.path.join(mylar.MULTIPLE_DEST_DIRS, os.path.basename(rescan['ComicLocation'])) != rescan['ComicLocation']:
|
||||
if all([mylar.MULTIPLE_DEST_DIRS is not None, mylar.MULTIPLE_DEST_DIRS != 'None', os.path.join(mylar.MULTIPLE_DEST_DIRS, os.path.basename(rescan['ComicLocation'])) != rescan['ComicLocation'], os.path.exists(os.path.join(mylar.MULTIPLE_DEST_DIRS, os.path.basename(rescan['ComicLocation'])))]):
|
||||
logger.fdebug(module + 'multiple_dest_dirs:' + mylar.MULTIPLE_DEST_DIRS)
|
||||
logger.fdebug(module + 'dir: ' + rescan['ComicLocation'])
|
||||
logger.fdebug(module + 'os.path.basename: ' + os.path.basename(rescan['ComicLocation']))
|
||||
|
@ -930,7 +930,6 @@ def forceRescan(ComicID, archive=None, module=None):
|
|||
fnd_iss_except = 'None'
|
||||
|
||||
fcdigit = helpers.issuedigits(temploc)
|
||||
|
||||
if int(fcdigit) == int_iss:
|
||||
logger.fdebug(module + ' [' + str(reiss['IssueID']) + '] Issue match - fcdigit: ' + str(fcdigit) + ' ... int_iss: ' + str(int_iss))
|
||||
|
||||
|
|
|
@ -1276,16 +1276,21 @@ class WebInterface(object):
|
|||
if dateload is None:
|
||||
IssueDate = None
|
||||
StoreDate = None
|
||||
Publisher = None
|
||||
SeriesYear = None
|
||||
else:
|
||||
IssueDate = dateload['IssueDate']
|
||||
StoreDate = dateload['StoreDate']
|
||||
|
||||
Publisher = dateload['IssuePublisher']
|
||||
SeriesYear = dateload['SeriesYear']
|
||||
|
||||
if ComicYear is None: ComicYear = SeriesYear
|
||||
logger.info(u"Marking " + ComicName + " " + ComicIssue + " as wanted...")
|
||||
logger.info('Marking ' + ComicName + ' #' + ComicIssue + ' as wanted...')
|
||||
logger.fdebug('publisher: ' + Publisher)
|
||||
controlValueDict = {"IssueArcID": IssueArcID}
|
||||
newStatus = {"Status": "Wanted"}
|
||||
myDB.upsert("readinglist", newStatus, controlValueDict)
|
||||
foundcom, prov = search.search_init(ComicName=ComicName, IssueNumber=ComicIssue, ComicYear=ComicYear, SeriesYear=None, Publisher=None, IssueDate=IssueDate, StoreDate=StoreDate, IssueID=None, AlternateSearch=None, UseFuzzy=None, ComicVersion=None, SARC=SARC, IssueArcID=IssueArcID)
|
||||
foundcom, prov = search.search_init(ComicName=ComicName, IssueNumber=ComicIssue, ComicYear=ComicYear, SeriesYear=None, Publisher=Publisher, IssueDate=IssueDate, StoreDate=StoreDate, IssueID=None, AlternateSearch=None, UseFuzzy=None, ComicVersion=None, SARC=SARC, IssueArcID=IssueArcID)
|
||||
if foundcom == "yes":
|
||||
logger.info(u"Downloaded " + ComicName + " #" + ComicIssue + " (" + str(ComicYear) + ")")
|
||||
controlValueDict = {"IssueArcID": IssueArcID}
|
||||
|
|
Loading…
Reference in a new issue