summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-12-22 13:25:53 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-12-22 13:25:53 +0100
commitdb6de87ca23f362e82b6fd3de374b4be64bb28cb (patch)
treeeb74892a75302f87f19bca698d0ef747c4c5ecc0 /scripts
parent3307df446f18add4b4fba27579178228ceabfc3a (diff)
parent64ef8e9025a9b7abe7e1ba38ac6294811a69f503 (diff)
downloadqutebrowser-db6de87ca23f362e82b6fd3de374b4be64bb28cb.tar.gz
qutebrowser-db6de87ca23f362e82b6fd3de374b4be64bb28cb.zip
Merge remote-tracking branch 'origin/pr/5958'
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/importer.py51
1 files changed, 21 insertions, 30 deletions
diff --git a/scripts/importer.py b/scripts/importer.py
index bae483b09..111082072 100755
--- a/scripts/importer.py
+++ b/scripts/importer.py
@@ -22,27 +22,19 @@
"""Tool to import data from other browsers.
-Currently importing bookmarks from Netscape Bookmark files and Mozilla
-profiles is supported.
+Currently importing bookmarks from Netscape HTML Bookmark files, Chrome
+profiles, and Mozilla profiles is supported.
"""
import argparse
+import textwrap
import sqlite3
import os
import urllib.parse
import json
import string
-browser_default_input_format = {
- 'chromium': 'chrome',
- 'chrome': 'chrome',
- 'ie': 'netscape',
- 'firefox': 'mozilla',
- 'seamonkey': 'mozilla',
- 'palemoon': 'mozilla',
-}
-
def main():
args = get_args()
@@ -68,15 +60,9 @@ def main():
bookmark_types = ['bookmark', 'keyword']
if not output_format:
output_format = 'quickmark'
- if not input_format:
- if args.browser:
- input_format = browser_default_input_format[args.browser]
- else:
- #default to netscape
- input_format = 'netscape'
import_function = {
- 'netscape': import_netscape_bookmarks,
+ 'html': import_html_bookmarks,
'mozilla': import_moz_places,
'chrome': import_chrome,
}
@@ -87,20 +73,25 @@ def main():
def get_args():
"""Get the argparse parser."""
parser = argparse.ArgumentParser(
- epilog="To import bookmarks from Chromium, Firefox or IE, "
- "export them to HTML in your browsers bookmark manager. ")
- parser.add_argument(
- 'browser',
- help="Which browser? {%(choices)s}",
- choices=browser_default_input_format.keys(),
- nargs='?',
- metavar='browser')
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ epilog=textwrap.dedent('''
+ To import bookmarks, you'll need the path to your profile or an
+ exported HTML file from your browser's bookmark manager. Redirect
+ the output from this script to the appropriate file in your
+ qutebrowser config directory (listed in the output of :version),
+ usually done with the '>' operator; for example,
+ ./importer.py -i mozilla your_profile_path > ~/.config/qutebrowser/quickmarks
+
+ Common browsers with native input format support:
+ chrome: Chrome, Chromium, Edge
+ mozilla: Firefox, SeaMonkey, Pale Moon
+ '''))
parser.add_argument(
'-i',
'--input-format',
- help='Which input format? (overrides browser default; "netscape" if '
- 'neither given)',
- choices=set(browser_default_input_format.values()),
+ help="Which input format? Defaults to html",
+ choices=['html', 'mozilla', 'chrome'],
+ default='html',
required=False)
parser.add_argument(
'-b',
@@ -186,7 +177,7 @@ def opensearch_convert(url):
return search_escape(url.format(**subst)).replace('%s', '{}')
-def import_netscape_bookmarks(bookmarks_file, bookmark_types, output_format):
+def import_html_bookmarks(bookmarks_file, bookmark_types, output_format):
"""Import bookmarks from a NETSCAPE-Bookmark-file v1.
Generated by Chromium, Firefox, IE and possibly more browsers. Not all