global independent add_bookmark().
This commit is contained in:
parent
53da73b8db
commit
27ef1c9df5
58
buku
58
buku
@ -202,15 +202,15 @@ class BukuDb:
|
|||||||
|
|
||||||
return resultset[0][0]
|
return resultset[0][0]
|
||||||
|
|
||||||
def add_bookmark(self, keywords):
|
def add_bookmark(self, keywords, tag_manual=None, title_manual=None, desc=None):
|
||||||
"""Add a new bookmark
|
"""Add a new bookmark
|
||||||
|
|
||||||
Params: keywords (url + optional tags)
|
:param keywords: url + optional tags list
|
||||||
|
:param tag_manual: list of tags to add manually
|
||||||
|
:param title_manual: string title to add manually
|
||||||
|
:param desc: string description
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global tagManual
|
|
||||||
global titleManual
|
|
||||||
global description
|
|
||||||
tags = ','
|
tags = ','
|
||||||
meta = ''
|
meta = ''
|
||||||
url = keywords[0]
|
url = keywords[0]
|
||||||
@ -222,8 +222,8 @@ class BukuDb:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Process title
|
# Process title
|
||||||
if titleManual is not None:
|
if title_manual is not None:
|
||||||
meta = titleManual
|
meta = title_manual
|
||||||
else:
|
else:
|
||||||
meta = network_handler(url)
|
meta = network_handler(url)
|
||||||
if meta == '':
|
if meta == '':
|
||||||
@ -232,18 +232,18 @@ class BukuDb:
|
|||||||
print("Title: [%s]" % meta)
|
print("Title: [%s]" % meta)
|
||||||
|
|
||||||
# Process tags
|
# Process tags
|
||||||
if tagManual is not None and False == (tagManual[0] == ',' and len(tagManual) == 1):
|
if tag_manual is not None and False == (tag_manual[0] == ',' and len(tag_manual) == 1):
|
||||||
keywords = keywords + [','] + tagManual
|
keywords = keywords + [','] + tag_manual
|
||||||
|
|
||||||
if len(keywords) > 1:
|
if len(keywords) > 1:
|
||||||
tags = parse_tags(keywords[1:])
|
tags = parse_tags(keywords[1:])
|
||||||
|
|
||||||
# Process description
|
# Process description
|
||||||
if description is None:
|
if desc is None:
|
||||||
description = ''
|
desc = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.cur.execute('INSERT INTO bookmarks(URL, metadata, tags, desc) VALUES (?, ?, ?, ?)', (url, meta, tags, description))
|
self.cur.execute('INSERT INTO bookmarks(URL, metadata, tags, desc) VALUES (?, ?, ?, ?)', (url, meta, tags, desc))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
print("Added at index %d\n" % self.cur.lastrowid)
|
print("Added at index %d\n" % self.cur.lastrowid)
|
||||||
self.printdb(self.cur.lastrowid)
|
self.printdb(self.cur.lastrowid)
|
||||||
@ -1384,7 +1384,23 @@ bdb = BukuDb()
|
|||||||
|
|
||||||
# Add a record
|
# Add a record
|
||||||
if args.addurl is not None:
|
if args.addurl is not None:
|
||||||
bdb.add_bookmark(args.addurl)
|
bdb.add_bookmark(args.addurl, tagManual, titleManual, description)
|
||||||
|
|
||||||
|
# Update record
|
||||||
|
if update == True:
|
||||||
|
if len(args.update) == 0:
|
||||||
|
bdb.refreshdb(0)
|
||||||
|
elif not args.update[0].isdigit():
|
||||||
|
printmsg("Index must be a number >= 0", "ERROR")
|
||||||
|
bdb.close_quit(1)
|
||||||
|
elif int(args.update[0]) == 0:
|
||||||
|
bdb.refreshdb(0)
|
||||||
|
else:
|
||||||
|
if args.url is not None:
|
||||||
|
new_url = args.url[0]
|
||||||
|
else:
|
||||||
|
new_url = ''
|
||||||
|
bdb.update_bookmark(int(args.update[0]), new_url, tagManual, titleManual, description)
|
||||||
|
|
||||||
# Delete record(s)
|
# Delete record(s)
|
||||||
if args.delete is not None:
|
if args.delete is not None:
|
||||||
@ -1412,22 +1428,6 @@ if tagsearch == True:
|
|||||||
else:
|
else:
|
||||||
bdb.list_tags()
|
bdb.list_tags()
|
||||||
|
|
||||||
# Update record
|
|
||||||
if update == True:
|
|
||||||
if len(args.update) == 0:
|
|
||||||
bdb.refreshdb(0)
|
|
||||||
elif not args.update[0].isdigit():
|
|
||||||
printmsg("Index must be a number >= 0", "ERROR")
|
|
||||||
bdb.close_quit(1)
|
|
||||||
elif int(args.update[0]) == 0:
|
|
||||||
bdb.refreshdb(0)
|
|
||||||
else:
|
|
||||||
if args.url is not None:
|
|
||||||
new_url = args.url[0]
|
|
||||||
else:
|
|
||||||
new_url = ''
|
|
||||||
bdb.update_bookmark(int(args.update[0]), new_url, tagManual, titleManual, description)
|
|
||||||
|
|
||||||
# Print all records
|
# Print all records
|
||||||
if args.printindex is not None:
|
if args.printindex is not None:
|
||||||
if args.printindex < 0:
|
if args.printindex < 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user