
NS Commute Tracker
Source (link to git-repo or to original if based on someone elses unmodified work):
Note: the NS api allows us a total 50.000 parses a day. Please leave the update setting to 60 seconds or more, otherwise we will get blocked.
On the todo list are:
* Upgrade the layout of the text
* Include translation(s)
Version 1.4:
- Fixed bug in connection code
Version 1.3:
- Fixed bug in parsing code w.r.t. time
Version 1.2.1:
- Fixed bug in layout of label position
- Fixed bug in exception handling causing "Script Initialization Failed" messages
Version 1.2:
- Added button that opens travel advice and disruptions (if any).
Version 1.1:
- Added code for NS API with fallback on HTML parsing code
- Implemented patch of rbos
Ratings & Comments
17 Comments
Since yesterday (24 feb) I get: "object can't made be due to the following reason": script initialisatie mislukt. Is this a general problem, or a problem on my site?
The plasmoid runs fine on my 3 computers. I just deleted and reinstalled the kde-apps version and it still works. Unfortunately, this makes it harder to diagnose the problem. Since you have tried the script before, I assume that you still have a "python-kde4" package installed? What changed between when the plasmoid worked and now?
nothing changed. Wednesday it worked, next day it stopped working. Is there a way to run the script from the command line?
You can run this (www.nijf.nl/getNSInfo_API.py) and see if it produces output. If it does yield a string with information, then it is likely an issue or bug in the GUI code. If the aforementioned script fails, then the parsing code is faulty.
The output I get is: /var/tmp> python ./getNSInfo_API.py ('Journey from Eindhoven ==> Vleuten\nDeparture: 16:02, arrival: 17:13, with 1 transfer.', []) Which looks fine to me.
I found the bug and I will upload the new version later today. The exception handling routine I wrote was missing an exception class...
Tsscht why isn't it also for french transports... Ha this is quiet simple and quick to use!
Hi, is it possible to make the "possible disruption" link clickable, and have it refer to http://www.ns.nl/storingen/index.form. That would make it convenient to determine the actual disruption.
Good idea, I actually get specific information about the disruption, so I can link to that. I guess implementing that will be part of my commute tomorrow!
The new button works simple and nice :)
Can you this patch: --- NSSummary/contents/code/getNSInfo.py.org 2012-02-14 18:11:42.781711000 +0100 +++ NSSummary/contents/code/getNSInfo.py 2012-02-14 20:33:50.358883001 +0100 @@ -71,7 +71,10 @@ summaryText+=' and has a transfer at %s'%(t) summaryText+=' and will arrive at %s.'%(self.arrivalTime) if self.nrDisruptions != 0: - summaryText+='\nThere is(are) %s disruption(s).'%self.nrDisruptions + if self.nrDisruptions == "(1)": + summaryText+='\nThere is 1 disruption.' + else: + summaryText+='\nThere are %s disruptions.'%self.nrDisruptions return summaryText def parseNS(fromStation='Eindhoven',toStation='Vleuten'): It makes the disruption text nicer formatted
So there is actually a ns.nl url which has departure in its string. Is there any chance to integrate this into the public transport plasmoid? http://kde-apps.org/content/show.php/PublicTransport?content=106175 Searched a bit further and by now there is an API available http://www.ns.nl/api/api but access is limited.
I have no current plans to integrate it with the public transport plugin. The goal was to make a very minimal interface, so that I can have a quick glance at when/if I need to leave for the train. The public transport project is free to "use" my code of course. The parsing code is separated (somewhat) from the GUI. Thanks for pointing me to the API, that does look nice, and more convenient then parsing HTML code. Why I did not look for this, I do not know :) . I will actually get this in asap.
let me just remind everyone that NS sucks! ;)
let me just remember everyone that NS sucks! ;)
Finally a plasmoid for the Dutch railways :) Is there a Dutch translation for it?
Offering different translations is a good point/suggestion. I will have a look at the KDE mechanism for adding translations and implement this.