aboutsummaryrefslogtreecommitdiff
path: root/src/lib/data.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-24 23:06:32 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-24 23:06:32 +0200
commitd15d428a59df925c9cb25ea869d7007132cb4416 (patch)
treed3abf3896f0253dd67b009cf9def659224b7cad4 /src/lib/data.py
parentImport bookmarks from pinboard.in (diff)
downloadnewspipe-d15d428a59df925c9cb25ea869d7007132cb4416.tar.gz
newspipe-d15d428a59df925c9cb25ea869d7007132cb4416.tar.bz2
newspipe-d15d428a59df925c9cb25ea869d7007132cb4416.zip
Import from pinboard is now faster. Bookmarks are sorted by time.
Diffstat (limited to 'src/lib/data.py')
-rw-r--r--src/lib/data.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/data.py b/src/lib/data.py
index e87023c4..0ccea357 100644
--- a/src/lib/data.py
+++ b/src/lib/data.py
@@ -37,6 +37,7 @@ from flask import jsonify
from bootstrap import db
from web.models import User, Feed, Article
+from web.models.tag import BookmarkTag
from web.controllers import BookmarkController, BookmarkTagController
@@ -171,10 +172,10 @@ def import_pinboard_json(user, json_content):
tag_contr = BookmarkTagController(user.id)
bookmarks = json.loads(json_content.decode("utf-8"))
nb_bookmarks = 0
- for bookmark in bookmarks[:20]:
+ for bookmark in bookmarks:
tags = []
for tag in bookmark['tags'].split(' '):
- new_tag = tag_contr.create(text=tag.strip(), user_id=user.id)
+ new_tag = BookmarkTag(text=tag.strip(), user_id=user.id)
tags.append(new_tag)
bookmark_attr = {
'href': bookmark['href'],
@@ -182,6 +183,8 @@ def import_pinboard_json(user, json_content):
'title': bookmark['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'),
'tags': tags
}
new_bookmark = bookmark_contr.create(**bookmark_attr)
bgstack15