-u N refreshes page title at index N.

This commit is contained in:
Arun Prakash Jana 2016-04-22 08:42:17 +05:30
parent eec5f7a7c0
commit c492ccf6c4
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB
3 changed files with 18 additions and 17 deletions

View File

@ -125,8 +125,9 @@ You may need to use `sudo` with `PREFIX` depending on your permissions on destin
-m title manually specify the title, for -a, -i, -u -m title manually specify the title, for -a, -i, -u
-s keyword(s) search bookmarks for any keyword -s keyword(s) search bookmarks for any keyword
-S keyword(s) search bookmarks with all keywords -S keyword(s) search bookmarks with all keywords
-u N [URL] [tags] update all fields of entry at DB index N, N=0 refreshes -u N [URL] [tags] update all fields of entry at DB index N; if URL is omitted the
all titles from the web; if N!=0, URL must be provided title of entry at DB index N is refreshed from web, N=0 refreshes
all titles from the web; URL and tags update respective fields
Power toys Power toys
-e show bookmarks with empty titles or no tags -e show bookmarks with empty titles or no tags
@ -179,9 +180,9 @@ The assigned automatic index 15012014 is unique, one greater than highest index
3. **Add** a bookmark **without a title** (works for update and insert too): 3. **Add** a bookmark **without a title** (works for update and insert too):
$ buku -a -m none http://tuxdiary.com linux news, open source $ buku -a -m none http://tuxdiary.com linux news, open source
4. **Update** existing bookmark at index 15012014 with a new tag: 4. **Update** existing bookmark at index 15012014 with new URL and tags, fetch title from the web:
$ buku -u 15012014 http://tuxdiary.com linux news, open source, magazine $ buku -u 15012014 http://tuxdiary.com/ linux news, open source, magazine
Title: [TuxDiary | Linux, open source and a pinch of leisure.] Title: [TuxDiary | Linux, open source and a pinch of leisure.]
Updated index 15012014 Updated index 15012014
Tags are updated too. Original tags are removed. Tags are updated too. Original tags are removed.

18
buku
View File

@ -439,7 +439,7 @@ def AddUpdateEntry(conn, cur, keywords, index):
def dbRefresh(conn, cur): def dbRefresh(conn, cur, index):
"""Refresh ALL records in the database. Fetch title for each """Refresh ALL records in the database. Fetch title for each
bookmark from the web and update the records. Doesn't udpate bookmark from the web and update the records. Doesn't udpate
the record if title is empty. the record if title is empty.
@ -448,7 +448,10 @@ def dbRefresh(conn, cur):
Params: connection, cursor Params: connection, cursor
""" """
if index == 0:
cur.execute("SELECT id, url FROM bookmarks ORDER BY id ASC") cur.execute("SELECT id, url FROM bookmarks ORDER BY id ASC")
else:
cur.execute("SELECT id, url FROM bookmarks WHERE id = ?", (index,))
resultset = cur.fetchall() resultset = cur.fetchall()
for row in resultset: for row in resultset:
title = fetchTitle(row[1]) title = fetchTitle(row[1])
@ -966,8 +969,9 @@ def usage():
" -m title manually specify the title, for -a, -i, -u\n" " -m title manually specify the title, for -a, -i, -u\n"
" -s keyword(s) search bookmarks for any keyword\n" " -s keyword(s) search bookmarks for any keyword\n"
" -S keyword(s) search bookmarks with all keywords\n" " -S keyword(s) search bookmarks with all keywords\n"
" -u N [URL] [tags] update all fields of entry at DB index N, N=0 refreshes\n" " -u N [URL] [tags] update all fields of entry at DB index N; if URL is omitted the\n"
" all titles from the web; if N!=0, URL must be provided\n\n" " title of entry at DB index N is refreshed from web, N=0 refreshes\n"
" all titles from the web; URL and tags update respective fields\n\n"
"Power toys\n" "Power toys\n"
" -e show bookmarks with empty titles or no tags\n" " -e show bookmarks with empty titles or no tags\n"
@ -1174,14 +1178,10 @@ if addurl == True:
# Update record # Update record
if update == True: if update == True:
if int(entry) > 0:
if len(keywords) < 1: if len(keywords) < 1:
conn.close() dbRefresh(conn, cur, int(entry))
usage()
AddUpdateEntry(conn, cur, keywords, entry)
else: else:
dbRefresh(conn, cur) AddUpdateEntry(conn, cur, keywords, entry)
# Search tags, URLs, Title info # Search tags, URLs, Title info
if search == True: if search == True:

4
buku.1
View File

@ -162,11 +162,11 @@ Note that URL must precede tags. Multiple words in title must be within quotes.
.B buku -a -m none http://tuxdiary.com linux news, open source .B buku -a -m none http://tuxdiary.com linux news, open source
.PP .PP
.IP 4. 4 .IP 4. 4
\fBUpdate\fR existing bookmark at index 15012014 with a new tag: \fBUpdate\fR existing bookmark at index 15012014 with new URL and tags, fetch title from the web:
.PP .PP
.EX .EX
.IP .IP
.B buku -u 15012014 http://tuxdiary.com linux news, open source, magazine .B buku -u 15012014 http://tuxdiary.com/ linux news, open source, magazine
.EE .EE
.PP .PP
.IP "" 4 .IP "" 4