CalibreOneDriveSync is a Python project designed to synchronize a Calibre library with OneDrive and automatically reload the CalibreWeb database when changes in the metadata are detected. It helps keep your Calibre library updated with changes in OneDrive and ensures the CalibreWeb DB is refreshed accordingly.
- Synchronizes Calibre library with OneDrive.
- Detects changes in the
metadata.db
file and triggers a reload of the CalibreWeb DB. - Configurable intervals for synchronization and checks.
- Logging and error handling.
- Python 3.8 or later
-
Install Calibre-Web
-
Install OneDrive
Linux - abraunegg/onedrive
Windows (My app doesn't work for Windows right now)
-
Clone the Repository:
git clone https://github.com/Kristalkill/CalibreOneDriveSync.git cd CalibreOneDriveSync
-
Install Dependencies Using Poetry
With requirements.txt
pip install -r requirements.txt
With Poetry. Make sure it is installed. If not, install it by following the Poetry installation instructions.
poetry install
-
Setup .env or default_config.py
METADATA_DB_PATH: Path to the metadata.db file in your Calibre library. CPS_PATH: Path to the Calibre server script. PORT_CALIBRE_WEB: ~~Port number for the Calibre content server.~~ Currently left it 8083 TIME_CHECK_ONEDRIVE_SECOND: Interval in seconds to check for changes in OneDrive. LOG: Enable or disable logging (True or False).
-
Run script
With python
python3 main.pu
With Poetry
poetry run python main.py
-
Systemd Service Setup (Optional for Linux):
Create a user systemd service file
mkdir -p ~/.config/systemd/user sudo nano ~/.config/systemd/user/calibre-onedrive-sync.service
Then paste this and edit it
[Unit] Description=Calibre OneDrive Sync Service After=network.target [Service] ExecStart=/path/to/poetry/or/python /path/to/CalibreOneDriveSync/main.py WorkingDirectory=/path/to/CalibreOneDriveSync Restart=always User=your-username [Install] WantedBy=default.target
Usage
systemctl --user daemon-reload systemctl --user enable calibre-onedrive-sync.service systemctl --user start calibre-onedrive-sync.service
Or you can create global service
sudo nano /etc/systemd/system/calibre-onedrive-sync.service
Then paste this and edit it
[Unit] Description=Calibre OneDrive Sync After=network.target [Service] ExecStart=/path/to/poetry/or/python /path/to/CalibreOneDriveSync/main.py WorkingDirectory=/path/to/CalibreOneDriveSync Restart=always User=your-username [Install] WantedBy=multi-user.target
Usage
sudo systemctl daemon-reload sudo systemctl start calibre-onedrive-sync sudo systemctl enable calibre-onedrive-sync
This project is licensed under the MIT License. See the LICENSE file for more details.
I welcome contributions from the community! To contribute to this project, please follow these steps:
-
Fork the Repository:
Click the "Fork" button on the top right of the repository page.
-
Clone Your Fork:
git clone https://github.com/yourname/CalibreOneDriveSync.git
-
Create a New Branch:
git checkout -b feature-branch
-
Implement your changes or add a new feature.
-
Commit Your Changes:
git add . git commit -m "Describe your changes"
-
Push to Your Fork:
git push origin feature-branch
-
Create a Pull Request: Go to the original repository and submit a pull request with your changes.