Created
May 24, 2024 04:30
-
-
Save Granitosaurus/61c4da2e391a610c2646a42238068a6f to your computer and use it in GitHub Desktop.
export qutebrowser bookmarks to firefox compatible bookmarks HTML file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""convert qutebrowser bookmarks to firefox bookmark HTML file for importing to firefox""" | |
from pathlib import Path | |
from os import getenv | |
xdg_config = Path(getenv('XDG_CONFIG_HOME', Path.home() / '.config')) | |
bookmarks = (xdg_config / 'qutebrowser/bookmarks/urls').read_text().splitlines() | |
html = [ | |
'<!DOCTYPE NETSCAPE-Bookmark-file-1>', | |
'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">', | |
'<TITLE>Bookmarks</TITLE>', | |
'<H1>Bookmarks</H1>', | |
'<DL>' | |
] | |
for url in bookmarks: | |
url, text = url.split(' ', 1) | |
html.append(f'<DT><A HREF="{url}">{text}</A></DT>') | |
html.append('</DL>') | |
Path('bookmarks.html').write_text('\n'.join(html)) | |
print('Bookmarks have been successfully converted to HTML format to bookmarks.html file.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment