samuel-pratt / bc-ferries-api

🛳 The only public API for retrieving current data on BC Ferries sailings.
https://bcferriesapi.ca
MIT License
33 stars 11 forks source link

Adding support for late ferry data? #27

Open daytonturner opened 2 years ago

daytonturner commented 2 years ago

Hi, just came across your API when attempting to build a BCFerries module for HomeAssistant, thanks for keeping this up to date!

The only other module I found was a bcferries python module that is 7 years old and definitely no longer works, sadly.

The one thing they exposed in theirs that I think yours could benefit from, is exposing whether or not the ferry in question is late or not. For instance, the page you could get this from for Langdale<>Horseshoe Bay would be: https://www.bcferries.com/current-conditions/departures?terminalCode=LNG

I was going to take a crack at adding a parser for this data, but wondering if you or anyone else has already attempted this, or if you are aware of a reason it wouldn't work?

samuel-pratt commented 2 years ago

I haven't attempted it yet, honestly I didn't know this info was available on their site. I don't think it would be too hard to add a 'late' field to each sailing on the api, checking that page for the next ferry, and if the text is anything but "On time" set it to true.

I'm currently working on a larger update to revamp the api to be used with a ferry app I'm building, I'll look at adding this to the update.

daytonturner commented 2 years ago

That would be awesome! Given that they return "late" or "cancelled" results of each sailing time, I would suspect you could even match these up for all of the results - in some cases, when there are heavy delays, it cam be helpful to know if the next 2 sailings are late, but the 3rd isn't. They post this ahead of time sometimes, if they know mechanical issues or weather are going to resolve themselves around a certain timeframe.

I dont know if you have a github sponsor page set up (kind of like a tip jar idea that github announced a few years ago) but if you do, I'd be happy to send you a donation for your time!

samuel-pratt commented 2 years ago

I agree, having that info for all possible sailings would be very helpful, I'll make sure to add that when I do the update.

I didn't have a sponsor page set up but I just made one, nobody's ever asked about that before. Feel no obligation to do so but anything would be greatly appreciated, and would all go to hosting this project. Thanks!

samuel-pratt commented 2 years ago

I've just updated the API with the larger changes, and have included a spot on sailing data for vessel status to be included. I'll look into adding it next week, but this update will also require some changes to any current usage of the api.

daytonturner commented 2 years ago

Nice job!

Looking forward to trying it out


From: Sam Pratt @.> Sent: Wednesday, March 23, 2022 11:12:02 AM To: samuel-pratt/bc-ferries-api @.> Cc: daytonturner @.>; Author @.> Subject: Re: [samuel-pratt/bc-ferries-api] Adding support for late ferry data? (Issue #27)

I've just updated the API with the larger changes, and have included a spot on sailing data for vessel status to be included. I'll look into adding it next week, but this update will also require some changes to any current usage of the api.

— Reply to this email directly, view it on GitHubhttps://github.com/samuel-pratt/bc-ferries-api/issues/27#issuecomment-1076661617, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACZEPSMXQVKFZEJRA33IDOTVBNNHFANCNFSM5RJBZKHQ. You are receiving this because you authored the thread.Message ID: @.***>

daytonturner commented 1 year ago

So I happened to notice that delays are now showing up, relatively cleanly, in the API 'time' field.

I wonder if its possible to split the additional 'late' information out into its own field.

e.g.:

{"sailingDuration":"","sailings":[{"time":"11:45 AM Delayed approx. 1h",

Instead of having "Delayed approx. 1h" in time, I wonder if we could put it into the "vesselStatus" field, or another?

It will make parsing the fields much easier!