iCalSyncHub is a lightweight Python program that synchronizes multiple online iCal calendars into a single merged calendar. The merged calendar is then shared as an iCal file, which can be hosted on a web server or used locally. Designed for simplicity and automation, it periodically updates the merged calendar based on a configurable sync interval.
- Multi-Calendar Support: Combine events from two or more iCal calendars into one.
- Automatic Syncing: Automatically updates the merged calendar at a specified interval.
- Custom Configuration: Use a simple
.inifile to configure calendar URLs, output location, and sync frequency. - Portable Output: Generates a standard
.icsfile compatible with popular calendar apps like Google Calendar, Outlook, and Apple Calendar. - Error Handling: Resilient to network errors or invalid calendar formats.
- Python 3.6 or higher
- Required Python libraries:
requestsicalendarpytz
Install the dependencies using pip:
pip install requests icalendar pytz- Clone the repository:
git clone https://github.com/ramhee98/iCalSyncHub.git
cd iCalSyncHub- Copy the config_template.ini file and customize it according to your requirements:
cp config_template.ini config.ini
nano config.ini- Create a calendar_urls.txt file in the project directory, listing the calendar URLs to sync:
https://example.com/calendar1.ics
https://example.com/calendar2.ics- Run the program:
python sync_calendars.pyThe program will fetch the specified calendars, merge their events, and save the result as an iCal file at the configured location. It will then periodically sync the calendars based on the specified interval.
The config.ini file contains the following settings:
output_path: Path where the merged calendar file will be saved.filename: Optional. Predefined filename for the output calendar. If not set, a random filename will be generated.sync_interval: Time interval (in seconds) between calendar syncs, if set to 0 it will only sync once.retries: Number of retry attempts if fetching a calendar fails.delay: Time in seconds to wait between retry attempts.timeout: Maximum time in seconds to wait for a response from a calendar URL.show_details: Boolean. Set totrueto include event details (summary, description, location, etc.) in the merged calendar. Set tofalseto anonymize events and show only availability (e.g., "Busy").log_output: Specify where logs should be sent. Options are:console: Logs are displayed only on the console.file: Logs are saved only to the specified file.both: Logs are sent to both the console and the file (default).none: Disable logging entirely.
log_level: Logging level to control the verbosity of the output. Options areDEBUG,INFO,WARNING,ERROR, andCRITICAL. Default isINFO.log_file: File path for the log output. Default isicalsynchub.log. Logs will be rotated if a file path is provided.max_log_file_size: Maximum size of a single log file in MB before rotation. Default in MB is10.log_backup_count: Number of backup log files to keep after rotation. Default is5.
[settings]
output_path = /var/www/html/
filename = mycal.ics
sync_interval = 300
retries = 3
delay = 5
timeout = 10
show_details = true
log_output = both
log_level = INFO
log_file = icalsynchub.log
max_log_file_size = 10
log_backup_count = 5This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! If you find a bug or have an idea for improvement, feel free to open an issue or submit a pull request.
- Built using the icalendar library.
- Inspired by the need for seamless calendar management.