aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-02 13:16:23 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-02 13:16:23 +0100
commitb9d13f6489f8948b247ed045a2fd04a3c6ee9396 (patch)
treeed75a7a8bf0a0dbcba78becc40b1f4c7af614090
parentRemoved deprecated API. (diff)
downloadnewspipe-b9d13f6489f8948b247ed045a2fd04a3c6ee9396.tar.gz
newspipe-b9d13f6489f8948b247ed045a2fd04a3c6ee9396.tar.bz2
newspipe-b9d13f6489f8948b247ed045a2fd04a3c6ee9396.zip
fixed issue with the function to import bookmarks from a JSON file.
-rw-r--r--newspipe/lib/data.py13
-rw-r--r--newspipe/web/templates/layout.html1
-rw-r--r--newspipe/web/views/bookmark.py3
3 files changed, 12 insertions, 5 deletions
diff --git a/newspipe/lib/data.py b/newspipe/lib/data.py
index 571aaf63..7c6beff9 100644
--- a/newspipe/lib/data.py
+++ b/newspipe/lib/data.py
@@ -204,13 +204,20 @@ def import_pinboard_json(user, json_content):
for tag in bookmark["tags"].split(" "):
new_tag = BookmarkTag(text=tag.strip(), user_id=user.id)
tags.append(new_tag)
+ try:
+ # Pinboard format
+ description = bookmark["extended"]
+ time = datetime.datetime.strptime(bookmark["time"], "%Y-%m-%dT%H:%M:%SZ")
+ except Exception:
+ description = bookmark["description"]
+ time = datetime.datetime.strptime(bookmark["time"], "%Y-%m-%dT%H:%M:%S")
bookmark_attr = {
"href": bookmark["href"],
- "description": bookmark["extended"],
- "title": bookmark["description"],
+ "description": description,
+ "title": description,
"shared": [bookmark["shared"] == "yes" and True or False][0],
"to_read": [bookmark["toread"] == "yes" and True or False][0],
- "time": datetime.datetime.strptime(bookmark["time"], "%Y-%m-%dT%H:%M:%SZ"),
+ "time": time,
"tags": tags,
}
new_bookmark = bookmark_contr.create(**bookmark_attr)
diff --git a/newspipe/web/templates/layout.html b/newspipe/web/templates/layout.html
index d83333a3..1453c3fd 100644
--- a/newspipe/web/templates/layout.html
+++ b/newspipe/web/templates/layout.html
@@ -94,7 +94,6 @@
<a class="dropdown-item" href="{{ url_for('user.profile') }}"><i class="fa fa-user" aria-hidden="true"></i>&nbsp;{{ _('Profile') }}</a>
<a class="dropdown-item" href="{{ url_for('user.management') }}"><i class="fa fa-hdd-o" aria-hidden="true"></i>&nbsp;{{ _('Your data') }}</a>
<a class="dropdown-item" href="{{ url_for('about') }}">{{ _('About') }}</a>
- <a class="dropdown-item" href="{{ url_for('feeds.feeds') }}">{{ _('All') }}</a>
{% if current_user.is_admin %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ url_for('admin.dashboard') }}">{{ _('Dashboard') }}</a>
diff --git a/newspipe/web/views/bookmark.py b/newspipe/web/views/bookmark.py
index c46409e4..6b370658 100644
--- a/newspipe/web/views/bookmark.py
+++ b/newspipe/web/views/bookmark.py
@@ -263,6 +263,7 @@ def bookmarklet():
def import_pinboard():
bookmarks = request.files.get("jsonfile", None)
if bookmarks:
+ nb_bookmarks = import_pinboard_json(current_user, bookmarks.read())
try:
nb_bookmarks = import_pinboard_json(current_user, bookmarks.read())
flash(
@@ -272,7 +273,7 @@ def import_pinboard():
),
"success",
)
- except Exception as e:
+ except Exception:
flash(gettext("Error when importing bookmarks."), "error")
return redirect(redirect_url())
bgstack15