~darklands/mbta-rss

an unofficial program that converts alert feeds for public transport in Greater Boston to RSS
929bd97d — Ben O'Neill a month ago
fix incorrect identifier
8b331aef — Ben O'Neill a month ago
update README
f02173c2 — Ben O'Neill a month ago
add stop listing feature

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~darklands/mbta-rss
read/write
git@git.sr.ht:~darklands/mbta-rss

You can also use your local clone with git send-email.

#mbta2rss

This software utilizes the MBTA API to grab alerts and stop lists for public transit routes in Greater Boston.

#Features (check means implemented)

  • [X] Generate an RSS feed containing alerts, neatly formatted.
  • [X] Only include certain routes.
  • [X] Allow the user to use an API key.
  • [X] Export to Markdown instead of RSS.
  • [X] Only include alerts active at a certain time.
  • [X] Convert stop lists to Markdown format.
  • [ ] Convert route schedules to Markdown format.

#Dependencies

  • requests (pip install requests)

#Installation

Run the following as root:

make install

#Usage

#Basics

Run mbta2rss >out.xml. Then you can open the XML file in your favorite RSS feed reader.

#Options

  • -d datatype: choose type of data to grab (alerts or stops, default is alerts)
  • -k key: Use an API key.
  • -o fmt: Set output format (rss or md, default is rss).
  • -r routes: Set route(s) to look for (comma separated)
  • -t time: Set time filter to show alerts active at that time (default shows all times, "NOW" for alerts in effect now, must be in ISO 8601 time format).
  • -T title: document/feed title
  • -D description: document/feed description
  • -U url: upstream URL for RSS feed

#Use Cases

  • Set up a cron job to update alerts feed every hour or so.
  • Email alerts to you (for the route(s) you take or all routes).
  • Post alerts on a webpage.
  • View alerts in a RSS feed reader.

#Cron-based Alert Updater

Add the following to your crontab:

0 * * * * /usr/bin/mbta2rss -k "$MYAPIKEY" >$HOSTDIR/rss.xml

#Emailing Digests

An example of emailing a Markdown-formatted digest using the headmail filter script and sendmail:

mbta2rss -o md -k "$MYAPIKEY" -r "Orange,36" -t "NOW" | headmail "$FROM" "$TO" | sendmail -a \
"$ACCOUNT" -t "$TO"

If you wanted to convert it to HTML first, a Markdown to HTML filter must be used (like smu:

mbta2rss -o md -k "$MYAPIKEY" -r "Orange,36" -t "NOW" | smu | headmail "$FROM" "$TO" \
| msmtp -a "$MSMTPACCOUNT" -t "$TO"

#Publishing Alerts

	

It is possible to make a HTML webpage (no CSS included by default) for the web using the Markdown output format and piping it into a Markdown to HTML filter.

mbta2rss -o md -k "$MYAPIKEY" | smu >out.html

#Important Notes

  1. Without an API key, you are limited to 20 calls per minute.
  2. If you publish anything containing content related to this, make sure it is clear this is unofficial and not officially affiliated with the MBTA. They have a license agreement.
  3. Green Line routes are differenciated like so: "Green-B", "Green-C", "Green-D", "Green-E"

#Bugs

I don't know of any bugs but I know there are bound to be some so submit an issue or email me.

#Contributing

Please feel free to contribute. Email me patches or submit a pull request.