aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-06-12 23:45:46 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-06-12 23:45:46 +0200
commitc2e3aabfecef35dc007031c2f61b4bb0999aa14e (patch)
tree94fc026ac8f95bea381c6c8c8e65f92a68008b84 /src/lib
parenttest tag for bookmarks (diff)
downloadnewspipe-c2e3aabfecef35dc007031c2f61b4bb0999aa14e.tar.gz
newspipe-c2e3aabfecef35dc007031c2f61b4bb0999aa14e.tar.bz2
newspipe-c2e3aabfecef35dc007031c2f61b4bb0999aa14e.zip
JSON export of bookmarks (compatible with Pinboard)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/data.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/data.py b/src/lib/data.py
index 0ccea357..3d5ec495 100644
--- a/src/lib/data.py
+++ b/src/lib/data.py
@@ -190,3 +190,20 @@ def import_pinboard_json(user, json_content):
new_bookmark = bookmark_contr.create(**bookmark_attr)
nb_bookmarks += 1
return nb_bookmarks
+
+
+def export_bookmarks(user):
+ bookmark_contr = BookmarkController(user.id)
+ bookmarks = bookmark_contr.read()
+ export = []
+ for bookmark in bookmarks:
+ export.append({
+ 'href': bookmark.href,
+ 'description': bookmark.description,
+ 'title': bookmark.title,
+ 'shared': 'yes' if bookmark.shared else 'false',
+ 'toread': 'yes' if bookmark.to_read else 'false',
+ 'time': bookmark.time,
+ 'tags': ' '.join(bookmark.tags_proxy)
+ })
+ return jsonify(export)
bgstack15