diff --git a/.gitignore b/.gitignore index cdb93cd..e13487d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .python-version +.vscode \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..57021b1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "conventionalCommits.scopes": [ + "search" + ] +} \ No newline at end of file diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index c8e388d..bd9cac3 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.09.02.1' +VERSION_NO = '2021.09.13.1' # Starting value for score before deductions are taken. INITIAL_SCORE = 100 @@ -370,8 +370,13 @@ def before_xpath(self, ctx, found, html): '[contains (@class,"releaseDateLabel")]/span' ) ) - datetext = re.sub(r'[^0-9\-]', '', datetext) - date = self.getDateFromString(datetext) + + # Handle different date structures + cleaned_datetext = re.search(r'\d{2}[-]\d{2}[-]\d{2}', datetext) + if not cleaned_datetext: + cleaned_datetext = re.search(r'\d{2}[.]\d{2}[.]\d{4}', datetext) + + date = self.getDateFromString(cleaned_datetext.group(0)) language = self.getStringContentFromXPath( r, ( u'div/div/div/div/div/div/span/ul/li' @@ -452,17 +457,17 @@ def score_result(self, f, helper, i, info, valid_itemId, year): all_scores = [] # Album name score - all_scores.append( - self.score_album(helper, title) - ) + title_score = self.score_album(helper, title) + if title_score: + all_scores.append(title_score) # Author name score - all_scores.append( - self.score_author(author, helper) - ) + author_score = self.score_author(author, helper) + if author_score: + all_scores.append(author_score) # Library language score - all_scores.append( - self.score_language(helper, language) - ) + lang_score = self.score_language(helper, language) + if lang_score: + all_scores.append(lang_score) # Because builtin sum() isn't available sum_scores=lambda numberlist:reduce(lambda x,y:x+y,numberlist,0) @@ -839,6 +844,8 @@ def getDateFromString(self, string): return Datetime.ParseDate(string).date() except AttributeError: return None + except ValueError: + return None def getStringContentFromXPath(self, source, query): return source.xpath('string(' + query + ')')