Skip to content

alessioc42/bahn2ical

Repository files navigation

bahn2ical (Docker)

Dieser Container ermöglicht die Synchronisierung deiner Bahnreisen (DB Navigator) mit deinem Kalender.

Environment variables (required):

  • REFRESH_CRON - cron expression (e.g. 0 0 * * *) for when the calendar should be refreshed.
  • ICAL_SECRET - secret token used to access the ICS route (must be at least 64 characters).
  • BAHN_USER - Bahn username.
  • BAHN_PASS - Bahn password.
  • HTTP_PORT - port the server listens on inside the container (default: 3000).

Endpoints:

  • GET /health - health check.
  • GET /ical/:secret/bahn2ical.ics - returns the iCal content if :secret matches ICAL_SECRET.

Build and run (example):

# build
docker build -t bahn2ical:latest .

# run
docker run -d \
  -e REFRESH_CRON="0 0 * * *" \
  -e ICAL_SECRET="<your-64-plus-char-secret>" \
  -e BAHN_USER="you@example.com" \
  -e BAHN_PASS="yourpassword" \
  -e HTTP_PORT=3000 \
  -p 3000:3000 \
  --name bahn2ical bahn2ical:latest

# fetch calendar
curl http://localhost:3000/ical/<your-64-plus-char-secret>/bahn2ical.ics

Development and deployment information

bahn.de blocks IP ranges from major cloud providers to prevent scraping. For example, running this on Hetzner Cloud may not work. Major VPN providers and most public proxies are blocked as well.

Contributing

Main areas where help is welcome:

  1. Parsing and data collection: the script is currently resource-intensive because it starts a headless browser to perform the required requests. bahn.de uses an Akamai browser-validation SDK, which makes automated data collection considerably harder.
  2. Localization: calendar entries are currently only in English. Adding localization support would be great.
  3. Multi-user support: the container currently supports a single user. Adding support for multiple users would be appreciated.

About

Sync your bahn.de journeys via ical in your own calendar

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors