Use a default value if attribute missing from tag
This commit is contained in:
parent
98da644a9b
commit
81d1fd1e6a
@ -30,14 +30,14 @@ def _import_bookmark_tag(bookmark_tag: bs4.Tag, user: User):
|
|||||||
bookmark.url = url
|
bookmark.url = url
|
||||||
bookmark.date_added = datetime.utcfromtimestamp(int(link_tag['add_date']))
|
bookmark.date_added = datetime.utcfromtimestamp(int(link_tag['add_date']))
|
||||||
bookmark.date_modified = bookmark.date_added
|
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.title = link_tag.string
|
||||||
bookmark.owner = user
|
bookmark.owner = user
|
||||||
|
|
||||||
bookmark.save()
|
bookmark.save()
|
||||||
|
|
||||||
# Set tags
|
# Set tags
|
||||||
tag_string = link_tag['tags']
|
tag_string = link_tag.get('tags', '')
|
||||||
tag_names = parse_tag_string(tag_string)
|
tag_names = parse_tag_string(tag_string)
|
||||||
tags = get_or_create_tags(tag_names, user)
|
tags = get_or_create_tags(tag_names, user)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user