Modified README
This commit is contained in:
parent
af561487e6
commit
7dfcb2ba5c
186
README.md
186
README.md
@ -1,27 +1,36 @@
|
|||||||
# CalDAV2GoogleCalendar
|
# CalDAV2GoogleCalendar
|
||||||
|
|
||||||
This project synchronizes events from a CalDAV calendar to a specific Google Calendar.
|
<p align="center">
|
||||||
|
<img src="https://gitlab.com/uploads/-/system/project/avatar/64798757/logo.jpg" alt="caldav2google"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
A Python utility to synchronize events from a CalDAV calendar to Google Calendar, maintaining a local state to track changes.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Connects to a CalDAV server to fetch calendar events.
|
- One-way synchronization from CalDAV to Google Calendar
|
||||||
- Compares fetched events with locally stored events to identify new, updated, and deleted events.
|
- Intelligent change detection:
|
||||||
- Synchronizes changes to a specified Google Calendar:
|
- Adds new events
|
||||||
- Adds new events.
|
- Updates modified events
|
||||||
- Updates modified events.
|
- Removes deleted events
|
||||||
- Deletes removed events.
|
- Local state management to track synchronized events
|
||||||
|
- Detailed logging of synchronization activities
|
||||||
|
- Rate limiting to prevent API throttling
|
||||||
|
- Error handling with failed events tracking
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
### 1. Python Environment
|
### 1. Python Environment
|
||||||
Ensure you have Python 3.7 or higher installed. It is recommended to use a virtual environment.
|
- Python 3.10 or higher
|
||||||
|
- Poetry for dependency management
|
||||||
|
|
||||||
### 2. CalDAV Server
|
### 2. CalDAV Server Details
|
||||||
A CalDAV server should be set up and accessible. Ensure you have the following:
|
You'll need:
|
||||||
- CalDAV server URL
|
- CalDAV server URL
|
||||||
- Username
|
- Username
|
||||||
- Password
|
- Password
|
||||||
|
- Calendar name to synchronize
|
||||||
|
|
||||||
### 3. Google Calendar API Credentials
|
### 3. Google Calendar Setup
|
||||||
|
|
||||||
To interact with the Google Calendar API, follow these steps:
|
To interact with the Google Calendar API, follow these steps:
|
||||||
|
|
||||||
@ -38,85 +47,144 @@ To interact with the Google Calendar API, follow these steps:
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Clone this repository:
|
1. Clone the repository:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/your-username/caldav2googlecalendar.git
|
git clone https://gitlab.com/rogs/caldav2google.git
|
||||||
cd caldav2googlecalendar
|
cd caldav2google
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install dependencies using Poetry:
|
2. Install dependencies:
|
||||||
```bash
|
```bash
|
||||||
poetry install
|
poetry install
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Activate the virtual environment:
|
3. Create `.env` file:
|
||||||
|
```env
|
||||||
|
CALDAV_URL=https://your-caldav-server.com
|
||||||
|
CALDAV_USERNAME=your_username
|
||||||
|
CALDAV_PASSWORD=your_password
|
||||||
|
CALDAV_CALENDAR_NAME=your_calendar_name
|
||||||
|
GOOGLE_CALENDAR_NAME=target_google_calendar_name
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. Activate virtual environment:
|
||||||
```bash
|
```bash
|
||||||
poetry shell
|
poetry shell
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
2. Run synchronization:
|
||||||
|
|
||||||
1. Update the `CALDAV_URL`, `USERNAME`, and `PASSWORD` variables in the script to match your CalDAV server credentials.
|
|
||||||
2. Ensure the `LOCAL_SYNC_FILE` points to the file where locally synced events will be stored.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
1. Run the script:
|
|
||||||
```bash
|
```bash
|
||||||
python sync_caldav_to_google.py
|
python main.py
|
||||||
```
|
```
|
||||||
|
|
||||||
2. On the first run, a browser window will open for Google authentication. Grant the necessary permissions to access your Google Calendar.
|
On first run:
|
||||||
3. The script will:
|
- Browser opens for Google OAuth authentication
|
||||||
- Fetch events from the CalDAV calendar.
|
- Grant requested calendar permissions
|
||||||
- Compare with the locally stored events.
|
- Token is saved locally for future use
|
||||||
- Add, update, or delete events in the specified Google Calendar.
|
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
caldav2googlecalendar/
|
src/
|
||||||
├── sync_caldav_to_google.py # Main script
|
├── auth_google.py # Google Calendar authentication
|
||||||
├── pyproject.toml # Project metadata and dependencies
|
├── caldav_client.py # CalDAV server interactions
|
||||||
├── README.md # Project documentation
|
├── main.py # Main synchronization script
|
||||||
├── credentials.json # Google API credentials (not included in the repository)
|
├── sync_logic.py # Core synchronization logic
|
||||||
├── calendar_sync.json # Locally synced events
|
pyproject.toml # Project configuration
|
||||||
└── .venv/ # Virtual environment (not included in the repository)
|
env.example # Environment variables example file
|
||||||
|
.env # Environment variables
|
||||||
|
README.md # README instructions
|
||||||
|
credentials.json # Google OAuth credentials
|
||||||
|
token.pickle # Stored Google token
|
||||||
|
calendar_sync.json # Local sync state
|
||||||
```
|
```
|
||||||
|
|
||||||
## Logging
|
## Configuration Files
|
||||||
|
|
||||||
- The script provides detailed logs during execution:
|
### credentials.json
|
||||||
- Number of new, updated, and deleted events.
|
Downloaded from Google Cloud Console (required)
|
||||||
- Any errors encountered during synchronization.
|
|
||||||
|
### .env
|
||||||
|
```env
|
||||||
|
CALDAV_URL=https://caldav.example.com
|
||||||
|
CALDAV_USERNAME=user
|
||||||
|
CALDAV_PASSWORD=pass
|
||||||
|
CALDAV_CALENDAR_NAME=My Calendar
|
||||||
|
GOOGLE_CALENDAR_NAME=CalDAV Events
|
||||||
|
```
|
||||||
|
|
||||||
|
### calendar_sync.json
|
||||||
|
Automatically maintained by the script to track synchronization state.
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
The script provides robust error handling:
|
||||||
|
- Failed events are tracked and reported
|
||||||
|
- Rate limiting prevents API throttling
|
||||||
|
- Detailed error messages for troubleshooting
|
||||||
|
- Synchronization state preserved on failure
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### Common Issues
|
### Authentication Issues
|
||||||
|
|
||||||
#### 1. `HttpError 400` when adding events
|
#### Google Calendar
|
||||||
- Ensure the event data is correctly formatted (ISO 8601 format for `start` and `end` dates).
|
- Error: `Invalid client credentials`
|
||||||
- Check if required fields (`summary`, `start`, `end`) are missing.
|
- Verify `credentials.json` is correctly downloaded and placed
|
||||||
|
- Ensure OAuth consent screen is configured
|
||||||
|
|
||||||
#### 2. Authentication Issues
|
- Error: `Token has been expired or revoked`
|
||||||
- Ensure the `credentials.json` file is in the correct location.
|
- Delete `token.pickle`
|
||||||
- Delete the `token.pickle` file and re-authenticate by running the script again.
|
- Re-run script to authenticate
|
||||||
|
|
||||||
#### 3. CalDAV Connection Issues
|
#### CalDAV
|
||||||
- Verify the `CALDAV_URL`, `USERNAME`, and `PASSWORD` values.
|
- Error: `Could not connect to server`
|
||||||
- Test connectivity to the CalDAV server using another CalDAV client (e.g., Thunderbird).
|
- Check URL format and accessibility
|
||||||
|
- Verify network connectivity
|
||||||
|
- Confirm server SSL certificate if using HTTPS
|
||||||
|
|
||||||
## Contributions
|
### Synchronization Issues
|
||||||
|
|
||||||
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
|
- Error: `Calendar not found`
|
||||||
|
- Verify calendar names in `.env`
|
||||||
|
- Check calendar visibility/permissions
|
||||||
|
|
||||||
|
- Error: `Failed to add/update events`
|
||||||
|
- Check event data formatting
|
||||||
|
- Verify calendar write permissions
|
||||||
|
- Review API quotas and limits
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Pre-commit Hooks
|
||||||
|
```bash
|
||||||
|
poetry run pre-commit install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create feature branch
|
||||||
|
3. Commit changes
|
||||||
|
4. Push to branch
|
||||||
|
5. Submit pull request
|
||||||
|
|
||||||
|
Please:
|
||||||
|
- Follow existing code style
|
||||||
|
- Add tests for new features
|
||||||
|
- Update documentation
|
||||||
|
- Run pre-commit hooks
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the GNU General Public License v3.0 or later. See the LICENSE file for more details.
|
GNU General Public License v3.0 or later
|
||||||
|
|
||||||
## Acknowledgments
|
|
||||||
|
|
||||||
- [Radicale](https://radicale.org/) for providing a lightweight CalDAV server.
|
|
||||||
- [Google Calendar API](https://developers.google.com/calendar) for seamless calendar integration.
|
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
Built with:
|
||||||
|
- [caldav](https://pypi.org/project/caldav/) - CalDAV client library
|
||||||
|
- [google-api-python-client](https://github.com/googleapis/google-api-python-client) - Google Calendar API
|
||||||
|
- [python-dotenv](https://pypi.org/project/python-dotenv/) - Environment management
|
||||||
|
- [Poetry](https://python-poetry.org/) - Dependency management
|
||||||
|
Loading…
x
Reference in New Issue
Block a user