diff --git a/lib/brave.py b/lib/brave.py index b938e33..7b7f0e6 100644 --- a/lib/brave.py +++ b/lib/brave.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -137,8 +153,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +175,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +219,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ diff --git a/lib/chrome.py b/lib/chrome.py index 19005b4..58c7b3e 100644 --- a/lib/chrome.py +++ b/lib/chrome.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,11 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) output = [] output.append(["term", "normalized_term"]) @@ -137,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -275,6 +302,7 @@ class ClosedReason: chromeWriter.write_json("notifications", output) except Exception as e: print(e) + return 0 def parse_extensions(path): diff --git a/lib/edge.py b/lib/edge.py index 6449c79..eb24079 100644 --- a/lib/edge.py +++ b/lib/edge.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -137,8 +153,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +175,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +219,13 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 + output = [] output.append( [ diff --git a/lib/firefox.py b/lib/firefox.py index 8557db3..423e149 100644 --- a/lib/firefox.py +++ b/lib/firefox.py @@ -66,8 +66,12 @@ def parse_favicons(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_pages_w_icons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_pages_w_icons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["page_url"]) for entry in entries: @@ -110,8 +114,12 @@ def parse_cookies(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( ["name", "value", "host", "expiry", "lastAccessed", "creationTime"] @@ -139,8 +147,12 @@ def parse_formhistory(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_formhistory") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_formhistory") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( ["fieldname", "value", "timesUsed", "firstUsed", "lastUsed"] @@ -167,8 +179,12 @@ def parse_perms(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_perms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_perms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["origin", "type", "expireTime", "modificationTime"]) for entry in entries: @@ -192,8 +208,12 @@ def parse_bookmarks(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_bookmarks") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_bookmarks") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["title", "dateAdded", "lastModified"]) for entry in entries: @@ -215,8 +235,12 @@ def parse_inputhistory(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_inputhistory") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_inputhistory") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["places_id", "url", "input"]) for entry in entries: @@ -233,8 +257,12 @@ def parse_history(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_places") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_places") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -290,8 +318,12 @@ def enrich_history(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_historyvisits") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_historyvisits") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] # Defined in the source code # Link: https://searchfox.org/mozilla-central/source/toolkit/components/places/History.sys.mjs Line 762 @@ -322,8 +354,12 @@ def parse_history_metadata(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_places_metadata") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_places_metadata") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -397,8 +433,12 @@ def parse_downloads(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_annos") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_annos") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 entries.sort(key=itemgetter(1)) output = [] # Write names of fields diff --git a/lib/opera.py b/lib/opera.py index 661589e..df566d3 100644 --- a/lib/opera.py +++ b/lib/opera.py @@ -32,8 +32,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -77,8 +81,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -100,8 +108,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -118,8 +130,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -136,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -154,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -194,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ diff --git a/lib/yandex.py b/lib/yandex.py index 1ca0e72..bbcffe0 100644 --- a/lib/yandex.py +++ b/lib/yandex.py @@ -32,8 +32,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -77,8 +81,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -100,8 +108,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -118,8 +130,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -136,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -154,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -194,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [