browser/firefox: rewrite bookmark/history scripts (text only)
This commit is contained in:
parent
ff4506fdf9
commit
d492a84b66
|
@ -1,2 +0,0 @@
|
||||||
alias bm='ffbookmarks'
|
|
||||||
alias hist='ffhistory'
|
|
|
@ -1,14 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
|
||||||
from pyfzf import FzfPrompt
|
|
||||||
from lib.FirefoxProfile import FirefoxProfile
|
from lib.FirefoxProfile import FirefoxProfile
|
||||||
|
|
||||||
|
|
||||||
with FirefoxProfile.default() as ff:
|
with FirefoxProfile.default() as ff:
|
||||||
choice = FzfPrompt().prompt(ff.bookmarks())
|
print("\n".join(ff.bookmarks()))
|
||||||
if choice:
|
|
||||||
ff.browse("http" + choice[0].split(", http")[1])
|
|
||||||
else:
|
|
||||||
print("Aborted")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys
|
|
||||||
from pyfzf import FzfPrompt
|
|
||||||
from lib.FirefoxProfile import FirefoxProfile
|
from lib.FirefoxProfile import FirefoxProfile
|
||||||
|
|
||||||
|
|
||||||
with FirefoxProfile.default() as ff:
|
with FirefoxProfile.default() as ff:
|
||||||
choice = FzfPrompt().prompt(ff.history())
|
print("\n".join(ff.history()))
|
||||||
if choice:
|
|
||||||
ff.browse("http" + choice[0].split(", http")[1])
|
|
||||||
else:
|
|
||||||
print("Aborted")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sqlite3 as sqlite
|
import sqlite3 as sqlite
|
||||||
import os
|
import os
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from pyfzf import FzfPrompt
|
|
||||||
from sys import platform as _platform
|
from sys import platform as _platform
|
||||||
|
|
||||||
fzf = FzfPrompt()
|
|
||||||
|
|
||||||
class FirefoxProfile:
|
class FirefoxProfile:
|
||||||
def __init__(self, dbfile):
|
def __init__(self, dbfile):
|
||||||
self.db = sqlite.connect(dbfile)
|
self.db = sqlite.connect(dbfile)
|
||||||
|
@ -54,16 +49,17 @@ class FirefoxProfile:
|
||||||
return self._process(self.cur.fetchall())
|
return self._process(self.cur.fetchall())
|
||||||
|
|
||||||
def _process(self, data):
|
def _process(self, data):
|
||||||
lookup = {}
|
title_lookup = {}
|
||||||
result = []
|
url_lookup = {}
|
||||||
|
ret = []
|
||||||
for row in data:
|
for row in data:
|
||||||
title = (row[0] or "").encode('utf-8').strip()
|
title = row[0].encode('utf-8').decode()
|
||||||
url = (row[1] or "").encode('utf-8').strip()
|
url = row[1].encode('utf-8').decode()
|
||||||
key = ", ".join((title, url))
|
if url.startswith("http") and title not in title_lookup and url not in url_lookup:
|
||||||
if key not in lookup and row[1].startswith("http"):
|
title_lookup[title] = 1
|
||||||
lookup[key] = 1
|
url_lookup[url] = 1
|
||||||
result.append(key)
|
ret.append("{}, {}".format(title, url))
|
||||||
return result
|
return ret
|
||||||
|
|
||||||
def browse(self, url):
|
def browse(self, url):
|
||||||
if _platform.startswith("linux"):
|
if _platform.startswith("linux"):
|
||||||
|
|
Loading…
Reference in a new issue