From fbaa7affc79a0fc7fc793548ec972186ea7b2ba9 Mon Sep 17 00:00:00 2001 From: djdembeck Date: Mon, 30 Aug 2021 16:30:49 -0500 Subject: [PATCH 1/3] Don't add empty series --- Contents/Code/__init__.py | 6 +++--- Contents/Code/update_tools.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 738fa07..960fdb9 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -790,10 +790,10 @@ def add_series_to_moods(self, helper): """ Adds book series' to moods, since collections are not supported """ - - helper.metadata.moods.add(helper.series) + if helper.series: + helper.metadata.moods.add("Series: " + helper.series) if helper.series2: - helper.metadata.moods.add(helper.series2) + helper.metadata.moods.add("Series: " + helper.series2) def parse_series(self, helper): # Clean series diff --git a/Contents/Code/update_tools.py b/Contents/Code/update_tools.py index 2b551b0..80404ef 100644 --- a/Contents/Code/update_tools.py +++ b/Contents/Code/update_tools.py @@ -80,7 +80,7 @@ def writeInfo(self): # Log basic metadata stored in arrays multi_arr = [ - {'Genres & Series': self.metadata.genres}, + {'Genres': self.metadata.genres}, {'Moods(Authors)': self.metadata.moods}, {'Styles(Narrators)': self.metadata.styles}, ] From e5a6fd014d51bb5a0415bf6dcd449c1869b57e60 Mon Sep 17 00:00:00 2001 From: djdembeck Date: Mon, 30 Aug 2021 16:34:13 -0500 Subject: [PATCH 2/3] Bump version --- Contents/Code/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 960fdb9..215c9ea 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -10,7 +10,7 @@ from update_tools import UpdateTool from urls import SiteUrl -VERSION_NO = '2021.08.29.2' +VERSION_NO = '2021.08.30.1' # Delay used when requesting HTML, # may be good to have to prevent being banned from the site From 11e4e9a8e6d17fd643cff0706722c245bd27b12a Mon Sep 17 00:00:00 2001 From: djdembeck Date: Mon, 30 Aug 2021 17:21:33 -0500 Subject: [PATCH 3/3] Use real log levels --- Contents/Code/__init__.py | 13 +++++------ Contents/Code/logging.py | 44 +++++++++++++++++++++++++++++++---- Contents/Code/search_tools.py | 4 ++-- Contents/Code/update_tools.py | 2 +- Contents/DefaultPrefs.json | 16 +++++++++---- 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 215c9ea..0b56a59 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -34,7 +34,7 @@ def ValidatePrefs(): def Start(): - # HTTP.ClearCache() + HTTP.ClearCache() HTTP.CacheTime = CACHE_1WEEK HTTP.Headers['User-agent'] = ( 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0;' @@ -120,7 +120,7 @@ def search(self, results, media, lang, manual=False): log.debug( '* Artist: %s', media.artist ) - log.debug( + log.error( '****************************************' 'Not Ready For Artist Search Yet' '****************************************' @@ -140,7 +140,7 @@ def worker(self, queue, stoprequest): try: func(*args, **kargs) except Exception as e: - log.info(e) + log.error(e) queue.task_done() except Queue.Empty: continue @@ -184,7 +184,7 @@ def search(self, results, media, lang, manual): # Write search result status to log if not result: - log.info( + log.warn( 'No results found for query "%s"', normalizedName ) @@ -250,7 +250,7 @@ def update(self, metadata, media, lang, force=False): try: html = HTML.ElementFromURL(url, sleep=REQUEST_DELAY) except Exception as e: - log.info(e) + log.error(e) # Instantiate update helper update_helper = UpdateTool(force, lang, media, metadata, url) @@ -627,7 +627,6 @@ def date_missing(self, helper, html): r'([^\\])(\\(?![bfnrt\'\"\\/]|u[A-Fa-f0-9]{4}))' ) page_content = remove_inv_json_esc.sub(r'\1\\\2', page_content) - log.debug(page_content) json_data = self.json_decode(page_content) helper.re_parse_with_date_published(json_data) @@ -887,7 +886,7 @@ def worker(self, queue, stoprequest): try: func(*args, **kargs) except Exception as e: - log.info(e) + log.error(e) queue.task_done() except Queue.Empty: continue diff --git a/Contents/Code/logging.py b/Contents/Code/logging.py index d876a50..c2704c7 100644 --- a/Contents/Code/logging.py +++ b/Contents/Code/logging.py @@ -1,16 +1,50 @@ class Logging: - # Only prints message with debug mode def debug(self, message, *args): - if Prefs['debug']: - return Log(message, *args) + """ + Prints passed message with DEBUG TYPE, + when DEBUG pref enabled. + """ + if Prefs['logging_level'] == "DEBUG": + return Log.Debug(message, *args) # Prints any message you give def info(self, message, *args): - return Log(message, *args) + """ + Prints passed message with INFO TYPE, + when INFO or DEBUG pref enabled. + """ + if Prefs['logging_level'] == "DEBUG" or ( + Prefs['logging_level'] == "INFO" + ): + return Log(message, *args) + + def warning(self, message, *args): + """ + Prints passed message with INFO TYPE, + when DEBUG, INFO or WARN pref enabled. + """ + if Prefs['logging_level'] == "DEBUG" or ( + Prefs['logging_level'] == "INFO") or ( + Prefs['logging_level'] == "WARN" + ): + # No builtin warn, so use info level for it + return Log(message, *args) + + def error(self, message, *args): + """ + Prints passed message with ERROR TYPE, + when DEBUG, INFO, WARN or ERROR pref enabled. + """ + if Prefs['logging_level'] == "DEBUG" or ( + Prefs['logging_level'] == "INFO") or ( + Prefs['logging_level'] == "WARN") or ( + Prefs['logging_level'] == "ERROR" + ): + return Log.Error(message, *args) # For the below logging: # Default level is info - # Set debug by calling ('sometext', 'debug') + # Set debug by calling (msg='sometext', log_level='debug') # Prints a bunch of divider chars like --- def separator(self, msg=None, log_level="info"): diff --git a/Contents/Code/search_tools.py b/Contents/Code/search_tools.py index 74360db..96f660f 100644 --- a/Contents/Code/search_tools.py +++ b/Contents/Code/search_tools.py @@ -17,7 +17,7 @@ def __init__(self, lang, manual, media, results): def check_if_preorder(self, book_date): current_date = (date.today()) if book_date > current_date: - log.debug("Excluding pre-order book") + log.info("Excluding pre-order book") return True def get_id_from_url(self, item): @@ -29,7 +29,7 @@ def get_id_from_url(self, item): if asin: return asin - log.info('No Match: %s', url) + log.warn('No Match: %s', url) return None def pre_search_logging(self): diff --git a/Contents/Code/update_tools.py b/Contents/Code/update_tools.py index 80404ef..1f79b79 100644 --- a/Contents/Code/update_tools.py +++ b/Contents/Code/update_tools.py @@ -56,7 +56,7 @@ def re_parse_with_date_published(self, json_data): except AttributeError: continue except IndexError: - log.info( + log.warn( '"' + self.title + '", ' "only has one genre" ) diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json index 4a15b75..127cb3b 100644 --- a/Contents/DefaultPrefs.json +++ b/Contents/DefaultPrefs.json @@ -37,8 +37,14 @@ "type": "bool", "default": "false" },{ - "id": "debug", - "label": "Ouput debugging info in logs", - "type": "bool", - "default": "false" -}] + "id": "logging_level", + "label": "Level of plugin logging: ", + "type": "enum", + "values": [ + "DEBUG", + "INFO", + "WARN", + "ERROR" + ], + "default": "WARN" +}] \ No newline at end of file