From 81d1fd1e6aa49fb4af8d5a5b6bd9ce4261fa6a38 Mon Sep 17 00:00:00 2001 From: Arpit <9051659+arpitgogia@users.noreply.github.com> Date: Sat, 6 Jun 2020 22:57:43 +0530 Subject: [PATCH] Use a default value if attribute missing from tag --- bookmarks/services/importer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookmarks/services/importer.py b/bookmarks/services/importer.py index f0343c2..91aaccc 100644 --- a/bookmarks/services/importer.py +++ b/bookmarks/services/importer.py @@ -30,14 +30,14 @@ def _import_bookmark_tag(bookmark_tag: bs4.Tag, user: User): bookmark.url = url bookmark.date_added = datetime.utcfromtimestamp(int(link_tag['add_date'])) bookmark.date_modified = bookmark.date_added - bookmark.unread = link_tag['toread'] == '1' + bookmark.unread = link_tag.get('toread', '0') == '1' bookmark.title = link_tag.string bookmark.owner = user bookmark.save() # Set tags - tag_string = link_tag['tags'] + tag_string = link_tag.get('tags', '') tag_names = parse_tag_string(tag_string) tags = get_or_create_tags(tag_names, user)