diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cdb93cd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.python-version diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 8219521..c8e388d 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -10,11 +10,7 @@ from update_tools import UpdateTool from urls import SiteUrl -VERSION_NO = '2021.08.30.2' - -# Delay used when requesting HTML, -# may be good to have to prevent being banned from the site -REQUEST_DELAY = 1 +VERSION_NO = '2021.09.02.1' # Starting value for score before deductions are taken. INITIAL_SCORE = 100 @@ -23,8 +19,6 @@ # Any score lower than this will be ignored. IGNORE_SCORE = 45 -#THREAD_MAX = 20 - # Setup logger log = Logging() @@ -90,7 +84,7 @@ def findDateInTitle(self, title): return None def doSearch(self, ctx, url): - html = HTML.ElementFromURL(url, sleep=REQUEST_DELAY) + html = HTML.ElementFromURL(url) found = [] for r in html.xpath('//div[a/img[@class="yborder"]]'): @@ -120,7 +114,7 @@ def search(self, results, media, lang, manual=False): log.debug( '* Artist: %s', media.artist ) - log.error( + log.warn( '****************************************' 'Not Ready For Artist Search Yet' '****************************************' @@ -248,7 +242,10 @@ def update(self, metadata, media, lang, force=False): url = ctx['AUD_BOOK_INFO'] % metadata.id try: - html = HTML.ElementFromURL(url, sleep=REQUEST_DELAY) + html = HTML.ElementFromURL(url) + except UnboundLocalError as e: + log.error("Title no longer avaible on Audible: " + metadata.id) + return except Exception as e: log.error(e) @@ -349,7 +346,7 @@ def create_search_url(self, ctx, helper): return searchUrl def doSearch(self, ctx, url): - html = HTML.ElementFromURL(url, sleep=REQUEST_DELAY) + html = HTML.ElementFromURL(url) found = [] # Set append to the returned array from this function @@ -607,7 +604,6 @@ def scrape_book_metadata(self, ctx, helper, html): helper.date = date helper.genre_child = genre_child helper.genre_parent = genre_parent - # helper.url = murl helper.narrator = narrator helper.series = series helper.studio = studio diff --git a/Contents/Code/logging.py b/Contents/Code/logging.py index c2704c7..c5908bb 100644 --- a/Contents/Code/logging.py +++ b/Contents/Code/logging.py @@ -18,7 +18,7 @@ def info(self, message, *args): ): return Log(message, *args) - def warning(self, message, *args): + def warn(self, message, *args): """ Prints passed message with INFO TYPE, when DEBUG, INFO or WARN pref enabled. diff --git a/Contents/Code/update_tools.py b/Contents/Code/update_tools.py index 1f79b79..1721d1f 100644 --- a/Contents/Code/update_tools.py +++ b/Contents/Code/update_tools.py @@ -38,10 +38,14 @@ def re_parse_with_date_published(self, json_data): for c in data['author']: author_array.append(c['name']) self.author = ",".join(author_array) - + narrator_array = [] - for c in data['readBy']: - narrator_array.append(c['name']) + if 'readBy' in data: + for c in data['readBy']: + narrator_array.append(c['name']) + else: + log.warn("No narrator listed for: " + self.metadata.id) + narrator_array.append("[Unknown Artist]") self.narrator = ",".join(narrator_array) self.studio = data['publisher'] self.synopsis = data['description'] diff --git a/Contents/Code/urls.py b/Contents/Code/urls.py index bba9006..d52e544 100644 --- a/Contents/Code/urls.py +++ b/Contents/Code/urls.py @@ -1,5 +1,8 @@ from logging import Logging +# Setup logger +log = Logging() + class SiteUrl: intl_sites = { @@ -190,7 +193,3 @@ def SetupUrls(self): self.set_context_urls() return self.context - - -# Setup logger -log = Logging()