From db18866b0ac2bdd6a7c76d6841f7c5e1dd4e8321 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sun, 27 Jun 2021 12:29:41 +1000 Subject: [PATCH] Re #106 - handling empty title with gettr cleanup (#107) --- backend/html_tools.py | 13 ++++++++----- backend/store.py | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/html_tools.py b/backend/html_tools.py index 904910d2..d71c4fbd 100644 --- a/backend/html_tools.py +++ b/backend/html_tools.py @@ -13,11 +13,14 @@ def css_filter(css_filter, html_content): # Extract/find element def extract_element(find='title', html_content=''): - html_title = False + + #Re #106, be sure to handle when its not found + element_text = None soup = BeautifulSoup(html_content, 'html.parser') - title = soup.find(find) - if title and title.string is not None: - html_title = title.string.strip() + result = soup.find(find) + if result and result.string: + element_text = result.string.strip() + + return element_text - return html_title diff --git a/backend/store.py b/backend/store.py index fd5ec895..9cc2e5a7 100644 --- a/backend/store.py +++ b/backend/store.py @@ -185,6 +185,10 @@ class ChangeDetectionStore: self.__data['watching'][uuid]['viewed'] = False has_unviewed = True + # #106 - Be sure this is None on empty string, False, None, etc + if not self.__data['watching'][uuid]['title']: + self.__data['watching'][uuid]['title'] = None + self.__data['has_unviewed'] = has_unviewed return self.__data