Chromium support (#232)

* new: dev: chromium support

* new: dev: path for windows and mac osx
This commit is contained in:
rachmadani haryono 2017-11-07 08:56:58 +08:00 committed by Arun Prakash Jana
parent 2d037d00d7
commit 517ac6319d

14
buku.py
View File

@ -2052,6 +2052,7 @@ class BukuDb:
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
GC_BM_DB_PATH = '~/.config/google-chrome/Default/Bookmarks' GC_BM_DB_PATH = '~/.config/google-chrome/Default/Bookmarks'
CB_BM_DB_PATH = '~/.config/chromium/Default/Bookmarks'
DEFAULT_FF_FOLDER = os.path.expanduser('~/.mozilla/firefox') DEFAULT_FF_FOLDER = os.path.expanduser('~/.mozilla/firefox')
profile = get_firefox_profile_name(DEFAULT_FF_FOLDER) profile = get_firefox_profile_name(DEFAULT_FF_FOLDER)
@ -2059,6 +2060,7 @@ class BukuDb:
FF_BM_DB_PATH = '~/.mozilla/firefox/{}/places.sqlite'.format(profile) FF_BM_DB_PATH = '~/.mozilla/firefox/{}/places.sqlite'.format(profile)
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
GC_BM_DB_PATH = '~/Library/Application Support/Google/Chrome/Default/Bookmarks' GC_BM_DB_PATH = '~/Library/Application Support/Google/Chrome/Default/Bookmarks'
CB_BM_DB_PATH = '~/Library/Application Support/Chromium/Default/Bookmarks'
DEFAULT_FF_FOLDER = os.path.expanduser('~/Library/Application Support/Firefox') DEFAULT_FF_FOLDER = os.path.expanduser('~/Library/Application Support/Firefox')
profile = get_firefox_profile_name(DEFAULT_FF_FOLDER) profile = get_firefox_profile_name(DEFAULT_FF_FOLDER)
@ -2067,6 +2069,7 @@ class BukuDb:
elif sys.platform == 'win32': elif sys.platform == 'win32':
username = os.getlogin() username = os.getlogin()
GC_BM_DB_PATH = 'C:/Users/{}/AppData/Local/Google/Chrome/User Data/Default/Bookmarks'.format(username) GC_BM_DB_PATH = 'C:/Users/{}/AppData/Local/Google/Chrome/User Data/Default/Bookmarks'.format(username)
CB_BM_DB_PATH = 'C:/Users/{}/AppData/Local/Chromium/User Data/Default/Bookmarks'.format(username)
DEFAULT_FF_FOLDER = 'C:/Users/{}/AppData/Roaming/Mozilla/Firefox/'.format(username) DEFAULT_FF_FOLDER = 'C:/Users/{}/AppData/Roaming/Mozilla/Firefox/'.format(username)
profile = get_firefox_profile_name(DEFAULT_FF_FOLDER) profile = get_firefox_profile_name(DEFAULT_FF_FOLDER)
@ -2097,6 +2100,17 @@ class BukuDb:
except Exception: except Exception:
print('Could not import bookmarks from google-chrome') print('Could not import bookmarks from google-chrome')
try:
if self.chatty:
resp = input('Import bookmarks from chromium? (y/n): ')
if resp == 'y':
bookmarks_database = os.path.expanduser(CB_BM_DB_PATH)
if not os.path.exists(bookmarks_database):
raise FileNotFoundError
self.load_chrome_database(bookmarks_database, newtag, add_parent_folder_as_tag)
except Exception:
print('Could not import bookmarks from chromium')
try: try:
if self.chatty: if self.chatty:
resp = input('Import bookmarks from firefox? (y/n): ') resp = input('Import bookmarks from firefox? (y/n): ')