bookmarks-converter


Namebookmarks-converter JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/radam9/bookmarks-converter
SummaryConvert browser bookmarks files.
upload_time2024-08-23 15:16:54
maintainerNone
docs_urlNone
authorAdam Saleh
requires_python<4.0,>=3.11
licenseMIT
keywords bookmarks bookmarks converter bookmarks-converter bookmarks-parser bookmarks parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Bookmarks Converter

---
[![image](https://img.shields.io/github/actions/workflow/status/radam9/bookmarks-converter/build-deploy.yml?branch=main&style=flat-square)](https://github.com/radam9/bookmarks-converter)
[![image](https://img.shields.io/github/license/radam9/bookmarks-converter?style=flat-square)](https://pypi.org/project/bookmarks-converter/)
[![image](https://img.shields.io/pypi/pyversions/bookmarks-converter?style=flat-square)](https://pypi.org/project/bookmarks-converter/)


BookmarksConverter is a package that converts browser bookmark files, usable as a [`module`](#usage-as-module) or as a [CLI](#usage-as-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`](/src/bookmarks_converter/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](./bookmarks_file_structure.md#b-json)).
- For examples of supported `DB`, `HTML`, or `JSON` structures and formats, refer to the [test resources](tests/resources) or [bookmarks_file_structure.md](bookmarks_file_structure.md).
- Custom `DB` and `JSON` formats by BookmarksConverter are not browser-importable.

---
## Table of Contents
  - [Table of Contents](#table-of-contents)
    - [Python and OS Support](#python-and-os-support)
    - [Dependencies](#dependencies)
    - [Install](#install)
    - [Test](#test)
    - [Usage as Module](#usage-as-module)
    - [Usage as CLI](#usage-as-cli)
    - [License](#license)
---
### 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`   | &check; | &check; |
| `ubuntu-latest`  | &check; | &check; |
| `windows-latest` | &check; | &check; |


---
### Dependencies
The package relies on the following libraries:
- [BeautifulSoup4](https://www.crummy.com/software/BeautifulSoup/): used to parse the HTML files.
- [SQLAlchemy](https://www.sqlalchemy.org/): used to create and manager the database files.

---
### Install
Bookmarks Converter is available on [PYPI](https://pypi.org/project/bookmarks-converter/)
```bash
python -m pip install bookmarks-converter
```

---
### Test
To test the package you will need to clone the [git repository](https://github.com/radam9/bookmarks-converter).

```bash
# 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`](https://python-poetry.org/).

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

---
### Usage as Module
```python
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](https://github.com/pypa/pipx).
```bash
# 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:
```bash
# 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](LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/radam9/bookmarks-converter",
    "name": "bookmarks-converter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "bookmarks, bookmarks converter, bookmarks-converter, bookmarks-parser, bookmarks parser",
    "author": "Adam Saleh",
    "author_email": "radam9@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/68/4cd9bdd43f5dea23dc1088a3698346eb911640b0779c109822e76bb5591d/bookmarks_converter-1.0.0.tar.gz",
    "platform": null,
    "description": "# Bookmarks Converter\n\n---\n[![image](https://img.shields.io/github/actions/workflow/status/radam9/bookmarks-converter/build-deploy.yml?branch=main&style=flat-square)](https://github.com/radam9/bookmarks-converter)\n[![image](https://img.shields.io/github/license/radam9/bookmarks-converter?style=flat-square)](https://pypi.org/project/bookmarks-converter/)\n[![image](https://img.shields.io/pypi/pyversions/bookmarks-converter?style=flat-square)](https://pypi.org/project/bookmarks-converter/)\n\n\nBookmarksConverter is a package that converts browser bookmark files, usable as a [`module`](#usage-as-module) or as a [CLI](#usage-as-cli).\n\nBookmarksConverter supports the converters below:\n\n- Bookmarkie (custom formats)\n- Chrome/Chromium\n- Firefox\n\nThe converters can import and export bookmarks from and to the formats listed below:\n\n- Bookmarkie: `DB`, `HTML`, `JSON`\n- Chrome/Chromium: `HTML`, `JSON`\n- Firefox: `HTML`, `JSON`\n\nNotes:\n\n- Supports Netscape-Bookmark format for `HTML` files\n- The exported `HTML` files are compatible with all browsers.\n- Custom `DB` files are powered by SQLAlchemy ORM (see [`models.py`](/src/bookmarks_converter/models.py)).\n- 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](./bookmarks_file_structure.md#b-json)).\n- For examples of supported `DB`, `HTML`, or `JSON` structures and formats, refer to the [test resources](tests/resources) or [bookmarks_file_structure.md](bookmarks_file_structure.md).\n- Custom `DB` and `JSON` formats by BookmarksConverter are not browser-importable.\n\n---\n## Table of Contents\n  - [Table of Contents](#table-of-contents)\n    - [Python and OS Support](#python-and-os-support)\n    - [Dependencies](#dependencies)\n    - [Install](#install)\n    - [Test](#test)\n    - [Usage as Module](#usage-as-module)\n    - [Usage as CLI](#usage-as-cli)\n    - [License](#license)\n---\n### Python and OS Support\nThe package has been tested on GitHub Actions with the following OSs and Python versions:\n\n| OS \\ Python      | `3.12`  | `3.11`  |\n|:-----------------|:-------:|:-------:|\n| `macos-latest`   | &check; | &check; |\n| `ubuntu-latest`  | &check; | &check; |\n| `windows-latest` | &check; | &check; |\n\n\n---\n### Dependencies\nThe package relies on the following libraries:\n- [BeautifulSoup4](https://www.crummy.com/software/BeautifulSoup/): used to parse the HTML files.\n- [SQLAlchemy](https://www.sqlalchemy.org/): used to create and manager the database files.\n\n---\n### Install\nBookmarks Converter is available on [PYPI](https://pypi.org/project/bookmarks-converter/)\n```bash\npython -m pip install bookmarks-converter\n```\n\n---\n### Test\nTo test the package you will need to clone the [git repository](https://github.com/radam9/bookmarks-converter).\n\n```bash\n# Cloning with HTTPS\ngit clone https://github.com/radam9/bookmarks-converter.git\n\n# Cloning with SSH\ngit clone git@github.com:radam9/bookmarks-converter.git\n```\nthen you create and install the dependencies using [`Poetry`](https://python-poetry.org/).\n\n```bash\n# navigate to repo's folder\ncd bookmarks-converter\n# install the dependencies\npoetry install\n# run the tests\npoetry run pytest\n```\n\n---\n### Usage as Module\n```python\nfrom pathlib import Path\nfrom bookmarks_converter import Chrome, Firefox\nfrom bookmarks_converter.formats import save_json\n\n# initialize the converter\nfirefox = Firefox()\nchrome = Chrome()\n\n# import the bookmarks\ninput_file = Path(\"/path/to/input.html\")\ncontent = firefox.from_html(input_file)\n\n# convert to desired format\noutput_file = Path(\"/path/to/output.json\")\nbookmarks = chrome.as_json(content)\n\n# finally save the bookmarks\n# there are some helper files that could be useful for saving to files\nsave_json(bookmarks, output_file)\n```\n\n---\n### Usage as CLI\n\n`bookmarks-converter` cli can be installed inside a virtual environment or using [pipx](https://github.com/pypa/pipx).\n```bash\n# bookmarks-converter usages:\n# example 1\nbookmarks-converter -i ./input_bookmarks.db --input-format 'bookmarkie/db' --output-format 'chrome/html'\n\n# example 2\nbookmarks-converter -i ./some_bookmarks.html -I 'chrome/html' -o ./output_bookmarks.json -O 'firefox/json'\n```\n\nThe help message:\n```bash\n# use -h for to show the help message (shown in the code block below)\n$ bookmarks-converter --help\n\nusage: bookmarks-converter [-h] [-V] -i INPUT -I INPUT_FORMAT [-o OUTPUT] -O OUTPUT_FORMAT\n\nConvert your browser bookmarks file.\n\nThe bookmark format is composed of two parts separated by a slash: [CONVERTER]/[FORMAT], ex. 'firefox/html'\nWith the converter being one of the available converters: ('bookmarkie', 'chrome', 'firefox')\nAnd the format being one of the available formats: ('db', 'html', 'json')\n\nExample Usage:\n    bookmarks-converter -i ./input_bookmarks.db --input-format 'bookmarkie/db' --output-format 'chrome/html'\n    bookmarks-converter -i ./some_bookmarks.html -I 'chrome/html' -o ./output_bookmarks.json -O 'firefox/json'\n    \n\noptions:\n  -h, --help            show this help message and exit\n  -V, --version         show program's version number and exit\n  -i INPUT, --input INPUT\n                        Input bookmarks file\n  -I INPUT_FORMAT, --input-format INPUT_FORMAT\n                        The bookmark format of the input bookmarks file\n  -o OUTPUT, --output OUTPUT\n                        Output bookmarks file\n  -O OUTPUT_FORMAT, --output-format OUTPUT_FORMAT\n                        The bookmark format of the output bookmarks file\n```\n\n---\n### License\n[MIT License](LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Convert browser bookmarks files.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/radam9/bookmarks-converter",
        "Repository": "https://github.com/radam9/bookmarks-converter"
    },
    "split_keywords": [
        "bookmarks",
        " bookmarks converter",
        " bookmarks-converter",
        " bookmarks-parser",
        " bookmarks parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f69ff2dfed4cb4656c8ba56ee19d52453b43941a03d1eb264e9b95f44ef3f6ac",
                "md5": "dd25ddb81295401cce05a1ab802b238d",
                "sha256": "aeae3cdc6ded6f0cee2794941a129926426450240e3f58cd6238cb2d4c352e7a"
            },
            "downloads": -1,
            "filename": "bookmarks_converter-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd25ddb81295401cce05a1ab802b238d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 23662,
            "upload_time": "2024-08-23T15:16:53",
            "upload_time_iso_8601": "2024-08-23T15:16:53.510926Z",
            "url": "https://files.pythonhosted.org/packages/f6/9f/f2dfed4cb4656c8ba56ee19d52453b43941a03d1eb264e9b95f44ef3f6ac/bookmarks_converter-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89684cd9bdd43f5dea23dc1088a3698346eb911640b0779c109822e76bb5591d",
                "md5": "38a52c7f2743d3772a1957e54efcb5b8",
                "sha256": "c8a8140e3783dd0d311d32a40c70c229f3a3e9b4d221f797ce02dd964f864b8c"
            },
            "downloads": -1,
            "filename": "bookmarks_converter-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "38a52c7f2743d3772a1957e54efcb5b8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 17351,
            "upload_time": "2024-08-23T15:16:54",
            "upload_time_iso_8601": "2024-08-23T15:16:54.481890Z",
            "url": "https://files.pythonhosted.org/packages/89/68/4cd9bdd43f5dea23dc1088a3698346eb911640b0779c109822e76bb5591d/bookmarks_converter-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-23 15:16:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "radam9",
    "github_project": "bookmarks-converter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bookmarks-converter"
}
        
Elapsed time: 0.32875s