Merge branch 'phansch-netscape-bookmarks-import'
This commit is contained in:
commit
456aa8bc97
@ -180,6 +180,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* neeasade
|
* neeasade
|
||||||
* jnphilipp
|
* jnphilipp
|
||||||
* Tobias Patzl
|
* Tobias Patzl
|
||||||
|
* Philipp Hansch
|
||||||
* Peter Michely
|
* Peter Michely
|
||||||
* Link
|
* Link
|
||||||
* Larry Hynes
|
* Larry Hynes
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
"""Tool to import data from other browsers.
|
"""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,28 @@ import argparse
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = get_args()
|
args = get_args()
|
||||||
if args.browser == 'chromium':
|
if args.browser in ['chromium', 'firefox', 'ie']:
|
||||||
import_chromium(args.bookmarks)
|
import_netscape_bookmarks(args.bookmarks)
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
"""Get the argparse parser."""
|
"""Get the argparse parser."""
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
epilog="To import bookmarks from Chromium, export them to HTML in "
|
epilog="To import bookmarks from Chromium, Firefox or IE, "
|
||||||
"Chromium's bookmark manager.")
|
"export them to HTML in your browsers bookmark manager.")
|
||||||
parser.add_argument('browser', help="Which browser?", choices=['chromium'],
|
parser.add_argument('browser', help="Which browser?",
|
||||||
|
choices=['chromium', 'firefox', 'ie'],
|
||||||
metavar='browser')
|
metavar='browser')
|
||||||
parser.add_argument('bookmarks', help="Bookmarks file")
|
parser.add_argument('bookmarks', help="Bookmarks file")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def import_chromium(bookmarks_file):
|
def import_netscape_bookmarks(bookmarks_file):
|
||||||
"""Import bookmarks from a HTML file generated by Chromium."""
|
"""Import bookmarks from a NETSCAPE-Bookmark-file v1.
|
||||||
|
|
||||||
|
Generated by Chromium, Firefox, IE and possibly more browsers
|
||||||
|
"""
|
||||||
import bs4
|
import bs4
|
||||||
with open(bookmarks_file, encoding='utf-8') as f:
|
with open(bookmarks_file, encoding='utf-8') as f:
|
||||||
soup = bs4.BeautifulSoup(f, 'html.parser')
|
soup = bs4.BeautifulSoup(f, 'html.parser')
|
||||||
|
Loading…
Reference in New Issue
Block a user