1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-22 07:42:24 +00:00

FIX:(#599) 'Newer version available, you're 0 commits behind' error, FIX:(#572) On Windows systems, when metatagging enabled would not delete temporary files (Thanks uspider7), IMP: Removed redudant looping code from cmtagmylar module, FIX: Annuals now will display correctly without destroying table layout after changing any issue status on screen, IMP: Added .NOW to issue scanner checks, FIX: When selecting one-off from Weekly Pull-list and not on watchlist, would error out as no year provided

This commit is contained in:
evilhero 2013-12-30 14:30:50 -05:00
parent c93386586a
commit b27584af81
7 changed files with 150 additions and 195 deletions

View file

@ -419,7 +419,7 @@
</div>
<table id="annual_table" class="display">
<table class="display_no_select" id="annual_table">
<!-- <div class="ui-widget">

View file

@ -94,103 +94,30 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
shutil.rmtree( comicpath )
os.makedirs( comicpath )
# make a list of all CBR and CBZ files in downloadpath
if filename is None:
filename_list = glob.glob( os.path.join( downloadpath, "*.cbz" ) )
filename_list.extend( glob.glob( os.path.join( downloadpath, "*.cbr" ) ) )
## Takes all .cbr and .cbz files and dumps them to processing directory ##
fcount = 1
for f in filename_list:
shutil.move( f, comicpath)
## Changes filetype extensions when needed ##
cbr_list = glob.glob( os.path.join( comicpath, "*.cbr" ) )
for f in cbr_list:
if zipfile.is_zipfile( f ):
base = os.path.splitext( f )[0]
shutil.move( f, base + ".cbz" )
logger.fdebug('{0}: renaming {1} to be a cbz'.format( scriptname, os.path.basename( f ) ))
if file_extension_fixing:
cbz_list = glob.glob( os.path.join( comicpath, "*.cbz" ) )
for f in cbz_list:
try:
rar_test_cmd_output = "is not RAR archive" #default, in case of error
rar_test_cmd_output = subprocess.check_output( [ unrar_cmd, "t", f ] )
except:
pass
if not "is not RAR archive" in rar_test_cmd_output:
base = os.path.splitext( f )[0]
shutil.move( f, base + ".cbr" )
logger.fdebug('{0}: renaming {1} to be a cbr'.format( scriptname, os.path.basename( f ) ))
# Now rename all CBR files to RAR
cbr_list = glob.glob( os.path.join( comicpath, "*.cbr" ) )
for f in cbr_list:
base = os.path.splitext( f )[0]
shutil.move( f, base + ".rar" )
## Changes any cbr files to cbz files for insertion of metadata ##
if file_conversion:
rar_list = glob.glob( os.path.join( comicpath, "*.rar" ) )
for f in rar_list:
logger.fdebug('{0}: converting {1} to be zip format'.format( scriptname, os.path.basename( f ) ))
basename = os.path.splitext( f )[0]
zipname = basename + ".cbz"
# Move into the folder where we will be unrar-ing things
os.makedirs( unrar_folder )
os.chdir( unrar_folder )
# Extract and zip up
try:
output = check_output( [ unrar_cmd, "x", f ] )
#subprocess.Popen( [ unrar_cmd, "x", f ] ).communicate()
except CalledProcessError as e:
if e.returncode == 3:
logger.fdebug('[Unrar Error 3] - Broken Archive.')
elif e.returncode == 1:
logger.fdebug('[Unrar Error 1] - No files to extract.')
logger.fdebug('Marking this as an incomplete download.')
return "unrar error"
shutil.make_archive( basename, "zip", unrar_folder )
# get out of unrar folder and clean up
os.chdir( comicpath )
shutil.rmtree( unrar_folder )
## Changes zip to cbz
zip_list = glob.glob( os.path.join( comicpath, "*.zip" ) )
for f in zip_list:
base = os.path.splitext( f )[0]
shutil.move( f, base + ".cbz" )
## Tag each CBZ, and move it back to original directory ##
cbz_list = glob.glob( os.path.join( comicpath, "*.cbz" ) )
for f in cbz_list:
if issueid is None:
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "-f", "-o", "--verbose", "--nooverwrite", f ] ).communicate()
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "-f", "-o", "--verbose", "--nooverwrite", f ] ).communicate()
if fcount > 1:
logger.fdebug('More than one cbr/cbz within path, performing Post-Process on first file detected: ' + f)
break
shutil.move( f, comicpath )
filename = f #just the filename itself
fcount+=1
else:
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "-o", "--id", issueid, "--verbose", "--nooverwrite", f ] ).communicate()
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "-o", "--id", issueid, "--verbose", "--nooverwrite", f ] ).communicate()
shutil.move( f, downloadpath )
return
else:
shutil.move( filename, comicpath)
shutil.move( filename, comicpath )
filename = os.path.split(filename)[1] # just the filename itself
print comicpath
print os.path.join( comicpath, filename )
#print comicpath
#print os.path.join( comicpath, filename )
if filename.endswith('.cbr'):
f = os.path.join( comicpath, filename )
if zipfile.is_zipfile( f ):
print "zipfile detected"
#print "zipfile detected"
base = os.path.splitext( f )[0]
print base
print f
#print base
#print f
shutil.move( f, base + ".cbz" )
logger.fdebug('{0}: renaming {1} to be a cbz'.format( scriptname, os.path.basename( f ) ))
@ -250,7 +177,7 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
## Changes zip to cbz
f = os.path.join( comicpath, os.path.splitext(filename)[0] + ".zip" )
print "zipfile" + f
#print "zipfile" + f
try:
with open(f): pass
except:
@ -291,8 +218,11 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
logger.fdebug('Sucessfully moved file from temporary path.')
i = 0
os.chdir( mylar.PROG_DIR )
while i < 10:
try:
logger.fdebug('Attempting to remove: ' + comicpath)
shutil.rmtree( comicpath )
except:
time.sleep(.1)
@ -304,9 +234,3 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
return os.path.join(os.path.abspath(dirName),file_n)
## Clean up temp directory ##
#os.chdir( sabnzbdscriptpath )
#shutil.rmtree( comicpath )
## Will Run Mylar Post=processing In Future ##

View file

@ -57,6 +57,8 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None,sarc=None):
'\@']
issue_exceptions = ['AU',
'.INH',
'.NOW',
'AI',
'A',
'B',
@ -354,8 +356,14 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None,sarc=None):
logger.fdebug('DECIMAL ISSUE DETECTED [' + justthedigits + ']')
else:
for issexcept in issue_exceptions:
decimalexcept = False
if '.' in issexcept:
decimalexcept = True
issexcept = issexcept[1:] #remove the '.' from comparison...
if issexcept.lower() in poss_alpha.lower() and len(poss_alpha) <= len(issexcept):
justthedigits += poss_alpha
if decimalexcept:
issexcept = '.' + issexcept
justthedigits += issexcept #poss_alpha
logger.fdebug('ALPHANUMERIC EXCEPTION. COMBINING : [' + justthedigits + ']')
digitsvalid = "true"
break

View file

@ -638,6 +638,8 @@ def issuedigits(issnum):
int_issnum = (int(issnum[:-2]) * 1000) + ord('a') + ord('i')
elif 'inh' in issnum.lower():
int_issnum = (int(issnum[:-4]) * 1000) + ord('i') + ord('n') + ord('h')
elif 'now' in issnum.lower():
int_issnum = (int(issnum[:-4]) * 1000) + ord('n') + ord('o') + ord('w')
elif u'\xbd' in issnum:
issnum = .5
int_issnum = int(issnum) * 1000
@ -659,7 +661,7 @@ def issuedigits(issnum):
if len(decis) == 1:
decisval = int(decis) * 10
issaftdec = str(decisval)
if len(decis) == 2:
if len(decis) >= 2:
decisval = int(decis)
issaftdec = str(decisval)
try:

View file

@ -624,6 +624,8 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
# print "ai:" + str(int_issnum)
elif 'inh' in issnum.lower():
int_issnum = (int(issnum[:-4]) * 1000) + ord('i') + ord('n') + ord('h')
elif 'now' in issnum.lower():
int_issnum = (int(issnum[:-4]) * 1000) + ord('n') + ord('o') + ord('w')
elif u'\xbd' in issnum:
issnum = .5
int_issnum = int(issnum) * 1000
@ -1209,9 +1211,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
def issue_collection(issuedata,nostatus):
myDB = db.DBConnection()
logger.info('issue collection...')
if issuedata:
#logger.info('issuedata exists')
for issue in issuedata:
@ -1226,7 +1226,6 @@ def issue_collection(issuedata,nostatus):
if nostatus == 'False':
#logger.info('issue')
# check if the issue already exists
iss_exists = myDB.action('SELECT * from issues WHERE IssueID=?', [issue['IssueID']]).fetchone()

View file

@ -1013,6 +1013,10 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
D_ComicVersion = ComVersChk
F_ComicVersion = re.sub("[^0-9]", "", fndcomicversion)
#if this is a one-off, SeriesYear will be None and cause errors.
if SeriesYear is None:
S_ComicVersion = 0
else:
S_ComicVersion = str(SeriesYear)
logger.fdebug("FCVersion: " + str(F_ComicVersion))
logger.fdebug("DCVersion: " + str(D_ComicVersion))
@ -1068,8 +1072,8 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
logger.fdebug("integer value of issue we are looking for : " + str(intIss))
fnd_iss_except = None
comintIss = helpers.issuedigits(comic_iss)
logger.fdebug("issue we found for is : " + str(comic_iss))
comintIss = helpers.issuedigits(comic_iss)
logger.fdebug("integer value of issue we are found : " + str(comintIss))
#issue comparison now as well

View file

@ -41,6 +41,8 @@ def solicit(month, year):
else:
datestring = str(month) + str(year)
pagelinks = "http://www.comicbookresources.com/tag/solicits" + str(datestring)
logger.info('datestring:' + datestring)
logger.info('checking:' + pagelinks)
pageresponse = urllib2.urlopen ( pagelinks )
soup = BeautifulSoup (pageresponse)
cntlinks = soup.findAll('h3')
@ -155,11 +157,26 @@ def populate(link,publisher,shipdate):
resultURL = []
matched = "no"
upcome = []
get_next = False
prev_chk = False
while (i < lenabc):
titlet = abc[i] #iterate through the p pulling out only results.
#print ("titlet: " + str(titlet))
if "/news/preview2.php" in str(titlet):
if "/prev_img.php?pid" in str(titlet):
#solicits in 03-2014 have seperated <p> tags, so we need to take the subsequent <p>, not the initial.
get_next = True
i+=1
continue
elif "/news/preview2.php" in str(titlet):
prev_chk = True
get_next = False
elif get_next == True:
prev_chk = True
else:
prev_chk = False
get_next = False
if prev_chk == True:
tempName = titlet.findNext(text=True)
if ' TPB' not in tempName and ' HC' not in tempName and 'GN-TPB' not in tempName and 'for $1' not in tempName.lower() and 'subscription variant' not in tempName.lower():
#print publisher + ' found upcoming'
@ -234,7 +251,8 @@ def populate(link,publisher,shipdate):
#print ('issue#: ' + re.sub('#', '', issue))
#print ('extra info: ' + exinfo)
else:
print ('no issue # to retrieve.')
pass
#print ('no issue # to retrieve.')
i+=1
return upcome
#end.