From 922d340576266918a6c3c9855466a4b6628b2e1a Mon Sep 17 00:00:00 2001 From: evilhero Date: Mon, 9 Jun 2014 14:34:53 -0400 Subject: [PATCH] FIX:(#725) When using Experimental Search, if issue number is not seperate from title will create an int error, IMP: Abit more error logging in regards to ComicVine API usage --- README.md | 6 +++++- mylar/cv.py | 8 ++++++-- mylar/helpers.py | 8 ++++++++ mylar/importer.py | 12 ++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 60743033..1bc6da18 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ Mylar is an automated Comic Book (cbr/cbz) downloader program heavily-based on t Yes, it does work, yes there are still bugs, and for that reson I still consider it the definition of an 'Alpha Release'. -This application requires a version of the 2.7.x Python branch for the best results. 3.x is not supported. +This application requires a version of the 2.7.x Python branch for the best results (3.x is not supported) + + ** NEW ** + You will need to get your OWN ComicVine API Key for this application to fully work. + Failure to do that will result in limited (to None) ability to add/update/refresh series as well as other important functunality. To start it, type in 'python Mylar.py' from within the root of the mylar directory. Adding a --help option to the command will give a list of available options. diff --git a/mylar/cv.py b/mylar/cv.py index 832a2e58..e0004dc3 100755 --- a/mylar/cv.py +++ b/mylar/cv.py @@ -131,8 +131,12 @@ def GetComicInfo(comicid,dom): cntit = int(cntit) #retrieve the first xml tag (data) #that the parser finds with name tagName: - comic['ComicName'] = dom.getElementsByTagName('name')[trackcnt+1].firstChild.wholeText - comic['ComicName'] = comic['ComicName'].rstrip() + try: + comic['ComicName'] = dom.getElementsByTagName('name')[trackcnt+1].firstChild.wholeText + comic['ComicName'] = comic['ComicName'].rstrip() + except: + logger.error('There was a problem retrieving the given data from ComicVine. Ensure that www.comicvine.com is accessible AND that you have provided your OWN ComicVine API key.') + return try: comic['ComicYear'] = dom.getElementsByTagName('start_year')[0].firstChild.wholeText except: diff --git a/mylar/helpers.py b/mylar/helpers.py index c5718a9f..6f33e015 100755 --- a/mylar/helpers.py +++ b/mylar/helpers.py @@ -717,6 +717,14 @@ def issuedigits(issnum): if str(issnum).isdigit(): int_issnum = int( issnum ) * 1000 else: + count = 0 + for char in issnum: + if char.isalpha(): + count += 1 + if count > 5: + logger.error('This is not an issue number - not enough numerics to parse') + int_issnum = 999999999999999 + return int_issnum if 'au' in issnum.lower() and issnum[:1].isdigit(): int_issnum = (int(issnum[:-2]) * 1000) + ord('a') + ord('u') elif 'ai' in issnum.lower() and issnum[:1].isdigit(): diff --git a/mylar/importer.py b/mylar/importer.py index 643855eb..06b29dc6 100755 --- a/mylar/importer.py +++ b/mylar/importer.py @@ -482,11 +482,17 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c if CV_NoYearGiven == 'no': #if set to 'no' then we haven't pulled down the issues, otherwise we did it already issued = cv.getComic(comicid,'issue') + if issued is None: + logger.warn('Unable to retrieve data from ComicVine. Get your own API key already!') + return logger.info('Sucessfully retrieved issue details for ' + comic['ComicName'] ) #move to own function so can call independently to only refresh issue data #issued is from cv.getComic, comic['ComicName'] & comicid would both be already known to do independent call. issuedata = updateissuedata(comicid, comic['ComicName'], issued, comicIssues, calledfrom, SeriesYear=SeriesYear) + if issuedata is None: + logger.warn('Unable to complete Refreshing / Adding issue data - this WILL create future problems if not addressed.') + return if mylar.CVINFO or (mylar.CV_ONLY and mylar.CVINFO): if not os.path.exists(os.path.join(comlocation,"cvinfo")) or mylar.CV_ONETIMER: @@ -1039,6 +1045,9 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call #chkType comes from the weeklypulllist - either 'annual' or not to distinguish annuals vs. issues if comicIssues is None: comic = cv.getComic(comicid,'comic') + if comic is None: + logger.warn('Error retrieving from ComicVine - either the site is down or you are not using your own CV API key') + return if comicIssues is None: comicIssues = comic['ComicIssues'] if SeriesYear is None: @@ -1047,6 +1056,9 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call comicname = comic['ComicName'] if issued is None: issued = cv.getComic(comicid,'issue') + if issued is None: + logger.warn('Error retrieving from ComicVine - either the site is down or you are not using your own CV API key') + return n = 0 iscnt = int(comicIssues) issid = []