diff --git a/custom_exceptions_sample.csv b/custom_exceptions_sample.csv new file mode 100644 index 00000000..1808a173 --- /dev/null +++ b/custom_exceptions_sample.csv @@ -0,0 +1,21 @@ +# Mylar Custom Exception listings +# In an effort to map ComicVine to GCD correctly, use this. +# +# +# Make changes/additions, and rename this file to 'custom_exceptions.csv'. +# +# +# Required Format, : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series) +# ----Format Breakdown +# code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3) +# = 99 is mismatched names. If a series won't match on GCD, this is what you would put. +# ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen) +# GCDComicID = the correct GCD Comic ID that Mylar is to match with. +# GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/' +# use 'none' if you are not using an option (yes, it's necessary) +# +#-----Volume Spanning Series----- + +#-----Mismatched Names------ +#test +99,1111,22222,none diff --git a/exceptions.csv b/exceptions.csv index cbb62d78..480f7c98 100644 --- a/exceptions.csv +++ b/exceptions.csv @@ -1,16 +1,12 @@ -#Mylar Exception listings -# In an effort to map ComicVine to GCD correctly, use this. +# Mylar Exception listings +# In an effort to map ComicVine to GCD correctly, this file will be imported into Mylar. #---- -#Required Format : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series) -#----Format Breakdown -#code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3) - = 99 is mismatched names. If a series won't match on GCD, this is what you would put. -#ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen) -#GCDComicID = the correct GCD Comic ID that Mylar is to match with. -#GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/' -#use 'none' if you are not using an option (yes, it's necessary) -#-------- -#-------- +# +######### DO NOT USE THIS FILE TO ADD YOUR OWN EXCEPTIONS! ########### +# USE custom_exceptions.csv FOR USER-ADDED EXCEPTIONS. # +# NOT DOING THIS WILL RESULT IN LOSING YOUR USER-ADDED EXCEPTIONS. # +###################################################################### +# #-----Volume Spanning Series----- #Fantastic Four 4,2045,none,1482/10251/6029/11218/62349 diff --git a/mylar/__init__.py b/mylar/__init__.py index cdaef28b..e0a559c3 100755 --- a/mylar/__init__.py +++ b/mylar/__init__.py @@ -521,30 +521,46 @@ def dbcheck(): # c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)') #new - logger.info(u"Populating Exception listings into Mylar....") c.execute('DROP TABLE IF EXISTS exceptions') c.execute('CREATE TABLE IF NOT EXISTS exceptions (variloop TEXT, ComicID TEXT, NewComicID TEXT, GComicID TEXT)') - EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv') + # for Mylar-based Exception Updates.... + i = 0 + EXCEPTIONS = [] + EXCEPTIONS.append('exceptions.csv') + EXCEPTIONS.append('custom_exceptions.csv') - if not os.path.exists(EXCEPTIONS_FILE): - try: + while (i <= 1): + #EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv') + EXCEPTIONS_FILE = os.path.join(DATA_DIR, EXCEPTIONS[i]) + + if not os.path.exists(EXCEPTIONS_FILE): + try: + csvfile = open(str(EXCEPTIONS_FILE), "rb") + except (OSError,IOError): + if i == 1: + logger.error("No Custom Exceptions found. Using base exceptions only.") + else: + logger.error("Could not locate " + str(EXCEPTIONS[i]) + " file. Make sure it's in datadir: " + DATA_DIR) + break + else: csvfile = open(str(EXCEPTIONS_FILE), "rb") - except OSError: - logger.error('Could not locate exceptions.csv file. Check in datadir: ' + DATA_DIR) - else: - csvfile = open(str(EXCEPTIONS_FILE), "rb") + if i == 0: + logger.info(u"Populating Base Exception listings into Mylar....") + elif i == 1: + logger.info(u"Populating Custom Exception listings into Mylar....") - creader = csv.reader(csvfile, delimiter=',') + creader = csv.reader(csvfile, delimiter=',') - for row in creader: - try: - c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row) - except Exception, e: - #print ("Error - invald arguments...-skipping") - pass - csvfile.close() + for row in creader: + try: + c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row) + except Exception, e: + #print ("Error - invald arguments...-skipping") + pass + csvfile.close() + i+=1 #c.executemany("INSERT INTO exceptions VALUES (?, ?);", to_db)