diff --git a/scripts/importer.py b/scripts/importer.py index 51e01c106..027d48264 100755 --- a/scripts/importer.py +++ b/scripts/importer.py @@ -21,7 +21,7 @@ """Tool to import data from other browsers. -Currently only importing bookmarks from Chromium is supported. +Currently only importing bookmarks from Netscape Bookmark files is supported. """ @@ -30,24 +30,27 @@ import argparse def main(): args = get_args() - if args.browser == 'chromium': - import_chromium(args.bookmarks) + if args.browser in ['chromium', 'firefox', 'ie']: + import_netscape_bookmarks(args.bookmarks) def get_args(): """Get the argparse parser.""" parser = argparse.ArgumentParser( - epilog="To import bookmarks from Chromium, export them to HTML in " - "Chromium's bookmark manager.") - parser.add_argument('browser', help="Which browser?", choices=['chromium'], + 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=['chromium', 'firefox', 'ie'], metavar='browser') parser.add_argument('bookmarks', help="Bookmarks file") args = parser.parse_args() return args +def import_netscape_bookmarks(bookmarks_file): + """Import bookmarks from a NETSCAPE-Bookmark-file v1 -def import_chromium(bookmarks_file): - """Import bookmarks from a HTML file generated by Chromium.""" + Generated by Chromium, Firefox, Internet Explorer and possibly more browsers + """ import bs4 with open(bookmarks_file, encoding='utf-8') as f: soup = bs4.BeautifulSoup(f, 'html.parser')