Reformat API to return URL

This commit is contained in:
Arun Prakash Jana 2018-05-26 09:29:34 +05:30
parent 88b046775f
commit 7cea005918
No known key found for this signature in database
GPG Key ID: A75979F35C080412
2 changed files with 11 additions and 9 deletions

View File

@ -27,7 +27,7 @@
`buku` is a powerful bookmark manager written in Python3 and SQLite3. When I started writing it, I couldn't find a flexible cmdline solution with a private, portable, merge-able database along with seamless GUI integration. Hence, `Buku` (after my son's nickname, meaning *close to the heart* in my language).
`buku` fetches the title of a bookmarked url and stores it along with any user-provided comments and tags. You can use your favourite editor to compose and update bookmarks. With multiple search options, including regex and a deep scan mode (particularly for URLs), it can find any bookmark instantly. Multiple search results can be opened in the browser at once. There's an Easter egg to revisit random forgotten bookmarks too!
`buku` fetches the title of a bookmarked url and stores it along with any user-provided comments and tags. You can use your favourite editor to compose and update bookmarks. With multiple search options, including regex and a deep scan mode (particularly for URLs), it can find any bookmark instantly. Multiple search results can be opened in the browser at once. `buku` can look up the latest snapshot of a broken link on the Wayback Machine. There's an Easter egg to revisit random forgotten bookmarks too!
For GUI and browser integration (or to sync bookmarks with your favourite bookmark management service), refer to the wiki page on [System integration](https://github.com/jarun/Buku/wiki/System-integration). If you prefer the terminal, the [shell completion](#shell-completion) scripts can be handy.

18
buku.py
View File

@ -2433,8 +2433,8 @@ class BukuDb:
Returns
-------
bool
True on success, False on failure.
str
Wayback Machine URL, None if not cached
"""
from urllib.parse import quote_plus
@ -2443,7 +2443,7 @@ class BukuDb:
rec = self.get_rec_by_id(int(arg))
if not rec:
logerr('No matching index %d', int(arg))
return False
return None
else:
url = rec[1]
else:
@ -2456,14 +2456,15 @@ class BukuDb:
respobj = json.loads(resp.data.decode('utf-8'))
try:
if len(respobj['archived_snapshots']) and respobj['archived_snapshots']['closest']['available'] is True:
browse(respobj['archived_snapshots']['closest']['url'])
return True
manager.clear()
return respobj['archived_snapshots']['closest']['url']
except Exception:
pass
finally:
manager.clear()
return False
logerr('Uncached')
return None
def fixtags(self):
"""Undocumented API to fix tags set in earlier versions.
@ -4783,8 +4784,9 @@ POSITIONAL ARGUMENTS:
# Try to fetch URL from Wayback Machine
if args.cached:
if bdb.browse_cached_url(args.cached[0]) is False:
logerr('Not cached')
wbu = bdb.browse_cached_url(args.cached[0])
if wbu is not None:
browse(wbu)
# Report upstream version
if args.upstream: