mirror of https://github.com/evilhero/mylar
IMP: Added ComicTagger API option (v.1.1.15-beta) - if 1.1.15 used, will attempt to use personal CV API Key provided in Mylar, otherwise if a lower version or no personal CV API key provided will default to generic ComicTagger key
This commit is contained in:
parent
b6217b729b
commit
2ce158b2e3
|
@ -23,11 +23,17 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
|
|||
# ( User may have to modify, depending on their setup, but these are some guesses for now )
|
||||
|
||||
if platform.system() == "Windows":
|
||||
(x, y) = platform.architecture()
|
||||
if x == "64bit":
|
||||
comictagger_cmd = os.path.join(mylar.CMTAGGER_PATH, 'comictagger.exe')
|
||||
#if it's a source install.
|
||||
if os.path.isdir(os.path.join(mylar.CMTAGGER_PATH, '.git')):
|
||||
comictagger_cmd = os.path.join(mylar.CMTAGGER_PATH, 'comictagger.py')
|
||||
|
||||
else:
|
||||
#regardless of 32/64 bit install
|
||||
if 'comictagger.exe' in mylar.CMTAGGER_PATH:
|
||||
comictagger_cmd = mylar.CMTAGGER_PATH
|
||||
else:
|
||||
comictagger_cmd = os.path.join(mylar.CMTAGGER_PATH, 'comictagger.exe')
|
||||
|
||||
unrar_cmd = "C:\Program Files\WinRAR\UnRAR.exe"
|
||||
|
||||
# test for UnRAR
|
||||
|
@ -113,6 +119,7 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
|
|||
filename = f #just the filename itself
|
||||
fcount+=1
|
||||
else:
|
||||
# if the filename is identical to the parent folder, the entire subfolder gets copied since it's the first match, instead of just the file
|
||||
shutil.move( filename, comicpath )
|
||||
|
||||
filename = os.path.split(filename)[1] # just the filename itself
|
||||
|
@ -165,7 +172,7 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
|
|||
logger.fdebug('{0}: Unrar is ' + unrar_folder )
|
||||
try:
|
||||
#subprocess.Popen( [ unrar_cmd, "x", os.path.join(comicpath,basename) ] ).communicate()
|
||||
output = check_output( [ unrar_cmd, "x", baserar ] ) #os.path.join(comicpath,basename) ] )
|
||||
output = subprocess.check_output( [ unrar_cmd, 'x', baserar ] ) #os.path.join(comicpath,basename) ] )
|
||||
except CalledProcessError as e:
|
||||
if e.returncode == 3:
|
||||
logger.fdebug('[Unrar Error 3] - Broken Archive.')
|
||||
|
@ -208,7 +215,31 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
|
|||
logger.fdebug('destination path: ' + os.path.join(dirName,file_n))
|
||||
logger.fdebug('dirName: ' + dirName)
|
||||
logger.fdebug('absDirName: ' + os.path.abspath(dirName))
|
||||
## check comictagger version - less than 1.15.beta - take your chances.
|
||||
ctversion = subprocess.check_output( [ comictagger_cmd, "--version" ] )
|
||||
ctend = ctversion.find(':')
|
||||
ctcheck = re.sub("[^0-9]", "", ctversion[:ctend])
|
||||
ctcheck = re.sub('\.', '', ctcheck).strip()
|
||||
if int(ctcheck) >= int('1115'): #(v1.1.15)
|
||||
if mylar.COMICVINE_API == mylar.DEFAULT_CVAPI:
|
||||
logger.fdebug(ctversion[:ctend] + ' being used - no personal ComicVine API Key supplied. Take your chances.')
|
||||
use_cvapi = "False"
|
||||
else:
|
||||
logger.fdebug(ctversion[:ctend] + ' being used - using personal ComicVine API key supplied via mylar.')
|
||||
use_cvapi = "True"
|
||||
else:
|
||||
logger.fdebug(ctversion[:ctend] + ' being used - personal ComicVine API key not supported in this version. Good luck.')
|
||||
use_cvapi = "False"
|
||||
|
||||
if use_cvapi == "True":
|
||||
## Tag each CBZ, and move it back to original directory ##
|
||||
if issueid is None:
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "--cv-api-key", mylar.COMICVINE_API, "-f", "-o", "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "--cv-api-key", mylar.COMICVINE_API, "-f", "-o", "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
else:
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "--cv-api-key", mylar.COMICVINE_API, "-o", "--id", issueid, "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "--cv-api-key", mylar.COMICVINE_API, "-o", "--id", issueid, "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
else:
|
||||
if issueid is None:
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "-f", "-o", "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "-f", "-o", "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
|
@ -216,6 +247,7 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
|
|||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cr", "-o", "--id", issueid, "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
subprocess.Popen( [ comictagger_cmd, "-s", "-t", "cbl", "-o", "--id", issueid, "--verbose", "--nooverwrite", nfilename ] ).communicate()
|
||||
|
||||
|
||||
if os.path.exists(os.path.join(os.path.abspath(dirName),file_n)):
|
||||
logger.fdebug('Unable to move - file already exists.')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue