From a5acf0e3aa42d4f9f690d31fd64af4e5dff2b060 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 12 Feb 2020 11:35:40 +0000 Subject: don't similarity test empty s --- modules/title.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/title.py b/modules/title.py index f70f4785..df05546e 100644 --- a/modules/title.py +++ b/modules/title.py @@ -29,16 +29,17 @@ class Module(ModuleManager.BaseModule): title_word = title_word.lower() title_words.append(title_word.strip("'\"<>()")) - present = 0 - for title_word in title_words: - if title_word in url: - present += 1 - - similarity = present/len(title_words) - # if at least 80% of words are in the URL, too similar - if similarity >= 0.8: - return False - return True + if title_words: + present = 0 + for title_word in title_words: + if title_word in url: + present += 1 + + similarity = present/len(title_words) + # less than 80% similar, proceed + if similarity < 0.8: + return True + return False def _get_title(self, server, channel, url): if not urllib.parse.urlparse(url).scheme: -- cgit v1.3.1-10-gc9f91