- Python 65%
- HTML 31.2%
- CSS 2.9%
- JavaScript 0.9%
| config | ||
| data | ||
| scraper | ||
| static | ||
| templates | ||
| tests | ||
| .codex | ||
| .gitignore | ||
| app.py | ||
| cache.py | ||
| circle_line.md | ||
| circle_line.py | ||
| more_prices.md | ||
| networkrail_timetable.py | ||
| prices.md | ||
| pyproject.toml | ||
| README.md | ||
| requirements.txt | ||
| run.fcgi | ||
| tfl_fare.py | ||
| trip_planner.py | ||
Bristol Eurostar
Source: https://git.4angle.com/edward/bristol-eurostar
Plan a trip from Bristol Temple Meads to Europe via Eurostar.
Combines GWR trains (Bristol → Paddington) with Eurostar services (St Pancras → destination) and shows all valid same-day connections, including Circle Line times for the Paddington → St Pancras transfer. Displays GWR walk-on fares, Eurostar Standard prices, seat availability, and total journey cost.
Destinations
- Paris Gare du Nord
- Brussels Midi
- Lille Europe
- Amsterdam Centraal
- Rotterdam Centraal
- Cologne Hbf
How it works
Train times and prices come from three sources:
- Network Rail — planned UK train times queried locally from an imported SQLite timetable
- GWR — walk-on and Advance fares fetched asynchronously after journey times are displayed
- Eurostar — fetched from the Eurostar GraphQL API (single call returns timetable, Standard fares, and seat availability)
The Paddington → St Pancras transfer uses a real Circle Line timetable parsed from a TfL TransXChange XML file, accounting for walk time to the platform at Paddington and walk time from the platform to the St Pancras check-in.
Results are cached to disk by date and destination.
Connection constraints
Configurable via the search form. Defaults:
| Minimum Paddington → St Pancras | 50 min |
| Maximum Paddington → St Pancras | 110 min |
Valid range: 45–120 min (min), 60–180 min (max).
GWR fares
Walk-on single fares for Bristol Temple Meads → Paddington, selected automatically by departure time:
| Ticket | Price | Restriction (weekdays) |
|---|---|---|
| Super Off-Peak | £45.00 | Not valid 05:05–09:57 |
| Off-Peak | £63.60 | Not valid before 08:26 |
| Anytime | £138.70 | No restriction |
Weekends always use Super Off-Peak.
Setup
pip install -e ".[dev]"
Configuration
Copy or create config/local.py (gitignored) to override defaults:
CACHE_DIR = '/var/cache/bristol-eurostar'
CIRCLE_LINE_XML = '/path/to/output_txc_01CIR_.xml'
NETWORKRAIL_TIMETABLE_DB = '/path/to/timetable.sqlite3'
Defaults (in config/default.py) use ~/lib/data/tfl/ for TfL data and ~/lib/data/networkrail/timetable.sqlite3 for the UK timetable.
The Circle Line XML is a TfL TransXChange timetable file. The Paddington (H&C Line) stop is 9400ZZLUPAH1; the King's Cross St Pancras stop is 9400ZZLUKSX3.
Import the UK timetable
Download the daily all-operator full JSON SCHEDULE snapshot from Network Rail, then run:
python -m networkrail_timetable import /home/edward/lib/data/networkrail/2026-11-04_timetable.gz
# For a different database location (also set NETWORKRAIL_TIMETABLE_DB above):
python -m networkrail_timetable import /path/to/full.gz --database /path/to/timetable.sqlite3
The importer streams the gzip file twice: first to identify mainline Paddington trains and Temple Meads–Parkway feeder
train UIDs, then to retain all their schedule variants, including cancellations
and diversions that omit Paddington. It stores station-code mappings and public
calling times with day offsets. The completed database is validated and atomically
replaces the old file; failed imports leave the previous timetable intact. Run the
import as the app user, or ensure the app user can read the database. New databases
are published with mode 0644; replacements preserve the existing file mode.
When the web server runs as a different user, configure an absolute
NETWORKRAIL_TIMETABLE_DB path in config/local.py (~ resolves to the
web-server user’s home).
Repeat with each new daily full snapshot. Downloading/authentication and automatic scheduling are not configured by this command. Update extracts are deliberately rejected: they require sequential processing rather than snapshot replacement. The command prints the source timestamp, sequence number and imported record counts.
Lookups apply validity dates, weekdays and STP precedence before checking the selected route. Both directions use public boarding/alighting times, including trains that started the previous day. Within the imported date range, UK timetable lookups stay local. Beyond its last schedule date, the app tries GWR's direct-service timetable API and caches successful results for six hours, keyed by date, station and direction. It never reuses a different date's timetable or substitutes services for a local cancellation. GWR also has a search horizon: if neither source covers the date, the page says “UK timetable not yet available”, rather than “No rail connection”. Failed or empty fallback responses are not cached. Missing/unreadable databases and upstream failures produce an availability message. Fares continue loading separately.
This supports direct trains to/from mainline Paddington (PADTON) and, for
Bristol Temple Meads, two-train journeys changing at Bristol Parkway (BRSTPWY).
Re-import an existing snapshot to include the feeder services (schema version 2).
Older databases remain readable for direct trains.
Parkway connections allow a conservative 10–45 minutes to change and use each leg's actual service date, including overnight journeys. A change is omitted if a direct train departs no earlier and arrives no later. The remaining one-change options are similarly filtered to avoid unnecessarily early departures or later arrivals. Results show both Parkway times, available platforms, and change time.
GWR through-ticket fares for these connections load through a separate stream. The request specifies via Bristol Parkway; GWR's route details must confirm two train legs changing there, with all four planned times matching the displayed itinerary. Walk-on, Advance Standard and Advance First fares are keyed by the full itinerary, never just the first departure time. Prices from direct services are kept separate. Unmatched routes or unoffered ticket classes remain unconfirmed; we do not estimate a fare or reuse another train's price. Confirmed fares are cached for six hours and rechecked against the current itinerary keys. Direct trains retain their existing asynchronous fare requests.
Elizabeth line Paddington (PADTLL / PDX) is a separate station and is not included. Association-based through journeys across different UIDs are not
assembled. This is a planned timetable snapshot, not live running information;
VSTP changes, real-time delays and live cancellations are not consumed. Keep the
snapshot current, especially for engineering changes and future travel dates.
Eurostar timetable requests may still delay combined results on a cache miss.
Running
flask --app app run
Then open http://localhost:5000.
Tests
pytest
License
MIT