Home, Up

sbb2prowl.pl

Update January 2013:

The "prosurf" interface has been shutdown by SBB, see this Twitter discussion.


This Perl script pushes updates on delays of Swiss trains directly to your iPhone. The delays are grabbed from http://prosurf.sbb.ch. sbb2prowl.pl uses Apple's push notification framework taking advantage of the marvelous Prowl service and its iPhone client.

Sample Incident

Download script

Author

Stephan

E-Mail: mail@ping13.net
Twitter: ping13

Feel free to contact me, if you have any questions or feedback.

Disclaimer

I'm not affiliated with the SBB nor does the SBB endorse this script. It may stop functioning anytime or the SBB might block this.
Please use this script carefully as it may incur heavy traffic on SBB's system which is currently free to use.

Dependencies

Usage

  1. Satisfy all the above dependencies and create a YAML file for configuration.

  2. Go to http://prosurf.sbb.ch and identify the URLs of those stations you are interested in (like your primary stations for commuting).

Example:
I usually commute from Zurich HB. From http://prosurf.sbb.ch/ I figure, that this station has the URL http://prosurf.sbb.ch/pros/inter/prosurfservlet?TRANSACTION=004&LANGUAGE=d&PBP=ZUE&DIRECTION=2. You may choose any language (German, French, Italian, English).

  1. For each station, identify the final destination of the train you are interested in. You might specify several destinations per station.

Example:
I'm looking for trains going to "Basel SBB" and "Bern".

  1. Enter the collected information in the YAML file (see sample file). If you have more than one final destinations, seperate them with a vertical bar "|".

Example:

stations:
  Zuerich HB:
    terminus: Basel SBB|Bern
    station_url: http://prosurf.sbb.ch/pros/inter/prosurfservlet?TRANSACTION=004&LANGUAGE=d&PBP=ZUE&DIRECTION=2
  1. With a valid in API key in the YAML file and test the script

    perl sbb2prowl.pl sample.yml

Sample YAML file

  1. If you are satisfied with how everything works, you may put it in your crontab (on Linux machines):

    /10 * * * /path/to/sbb2prowl.pl mycfg.yml >>/path/to/crontab.log 2>>/path/to/crontab-error.log

Todo

Changes

none since V0.1

License

Copyright (C) 2009, mail@ping13.net

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.

Last modification: Di 19. Mär 13:38:07 CET 2013


Comments? Feedback?

Tweet  about it and mention my Twitter account @ping13 or send an e-mail to mail@ping13.net.
Home, Up