Skip to main content

Convert browser bookmarks files.

Project description

Bookmarks Converter


image image image

BookmarksConverter is a package that converts browser bookmark files, usable as a module or as a CLI.

BookmarksConverter supports the converters below:

  • Bookmarkie (custom formats)
  • Chrome/Chromium
  • Firefox

The converters can import and export bookmarks from and to the formats listed below:

  • Bookmarkie: DB, HTML, JSON
  • Chrome/Chromium: HTML, JSON
  • Firefox: HTML, JSON

Notes:

  • Supports Netscape-Bookmark format for HTML files
  • The exported HTML files are compatible with all browsers.
  • Custom DB files are powered by SQLAlchemy ORM (see models.py).
  • Chrome/Chromium JSON files cannot be directly imported but can be placed in the appropriate location (see bookmarks_file_structure.md - Chrome/Chromium - b. JSON).
  • For examples of supported DB, HTML, or JSON structures and formats, refer to the test resources or bookmarks_file_structure.md.
  • Custom DB and JSON formats by BookmarksConverter are not browser-importable.

Table of Contents


Python and OS Support

The package has been tested on GitHub Actions with the following OSs and Python versions:

OS \ Python 3.12 3.11
macos-latest
ubuntu-latest
windows-latest

Dependencies

The package relies on the following libraries:


Install

Bookmarks Converter is available on PYPI

python -m pip install bookmarks-converter

Test

To test the package you will need to clone the git repository.

# Cloning with HTTPS
git clone https://github.com/radam9/bookmarks-converter.git

# Cloning with SSH
git clone git@github.com:radam9/bookmarks-converter.git

then you create and install the dependencies using Poetry.

# navigate to repo's folder
cd bookmarks-converter
# install the dependencies
poetry install
# run the tests
poetry run pytest

Usage as Module

from pathlib import Path
from bookmarks_converter import Chrome, Firefox
from bookmarks_converter.formats import save_json

# initialize the converter
firefox = Firefox()
chrome = Chrome()

# import the bookmarks
input_file = Path("/path/to/input.html")
content = firefox.from_html(input_file)

# convert to desired format
output_file = Path("/path/to/output.json")
bookmarks = chrome.as_json(content)

# finally save the bookmarks
# there are some helper files that could be useful for saving to files
save_json(bookmarks, output_file)

Usage as CLI

bookmarks-converter cli can be installed inside a virtual environment or using pipx.

# bookmarks-converter usages:
# example 1
bookmarks-converter -i ./input_bookmarks.db --input-format 'bookmarkie/db' --output-format 'chrome/html'

# example 2
bookmarks-converter -i ./some_bookmarks.html -I 'chrome/html' -o ./output_bookmarks.json -O 'firefox/json'

The help message:

# use -h for to show the help message (shown in the code block below)
$ bookmarks-converter --help

usage: bookmarks-converter [-h] [-V] -i INPUT -I INPUT_FORMAT [-o OUTPUT] -O OUTPUT_FORMAT

Convert your browser bookmarks file.

The bookmark format is composed of two parts separated by a slash: [CONVERTER]/[FORMAT], ex. 'firefox/html'
With the converter being one of the available converters: ('bookmarkie', 'chrome', 'firefox')
And the format being one of the available formats: ('db', 'html', 'json')

Example Usage:
    bookmarks-converter -i ./input_bookmarks.db --input-format 'bookmarkie/db' --output-format 'chrome/html'
    bookmarks-converter -i ./some_bookmarks.html -I 'chrome/html' -o ./output_bookmarks.json -O 'firefox/json'
    

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -i INPUT, --input INPUT
                        Input bookmarks file
  -I INPUT_FORMAT, --input-format INPUT_FORMAT
                        The bookmark format of the input bookmarks file
  -o OUTPUT, --output OUTPUT
                        Output bookmarks file
  -O OUTPUT_FORMAT, --output-format OUTPUT_FORMAT
                        The bookmark format of the output bookmarks file

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bookmarks_converter-1.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

bookmarks_converter-1.0.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file bookmarks_converter-1.0.0.tar.gz.

File metadata

  • Download URL: bookmarks_converter-1.0.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure

File hashes

Hashes for bookmarks_converter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c8a8140e3783dd0d311d32a40c70c229f3a3e9b4d221f797ce02dd964f864b8c
MD5 38a52c7f2743d3772a1957e54efcb5b8
BLAKE2b-256 89684cd9bdd43f5dea23dc1088a3698346eb911640b0779c109822e76bb5591d

See more details on using hashes here.

File details

Details for the file bookmarks_converter-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bookmarks_converter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeae3cdc6ded6f0cee2794941a129926426450240e3f58cd6238cb2d4c352e7a
MD5 dd25ddb81295401cce05a1ab802b238d
BLAKE2b-256 f69ff2dfed4cb4656c8ba56ee19d52453b43941a03d1eb264e9b95f44ef3f6ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page