buku_import.py 502 B

12345678910111213
  1. from pathlib import Path
  2. import sqlite3
  3. def import_from_buku(store, buku_path: Path = None):
  4. if buku_path is None:
  5. buku_path = Path('~/.local/share/buku/bookmarks.db').expanduser()
  6. conn = sqlite3.connect(buku_path)
  7. cur = conn.cursor()
  8. query = '''SELECT URL, metadata, tags, desc FROM bookmarks'''
  9. for url, title, tags, desc in cur.execute(query):
  10. tags = [t.strip() for t in tags.split(',')]
  11. store.add('', url=url, title=title, tags=tags, description=desc)