Artemy Posted August 2, 2022 Posted August 2, 2022 NS (Nederlandse Spoorwegen) Train schedule for Alfred Alfred workflow for getting NS Train schedule. Getting started Prerequisites Project requires Python 3.8+ to run, which is not included by default with macOS. You can install Python 3 using this guide. ⚠️ Make sure to get API key from https://apiportal.ns.nl/ and set it as workflow environment variable NS_APIKEY during the installation. Downloading & Installing Download NS_Schedule.alfredworkflow file from the latest release at this project's Github Releases page and open it with Alfred. Change the value of NS_APIKEY variable to the value you've received from NS at the Prerequisites step. How to Use Open Alfred and type ns and names of two train stations you want to see schedule for. Workflow will display list of upcoming trains for the route you have specified. Pressing Enter on a displayed item will open it on NS website, so you can get more details. Built With Python 3.8 Feedback & Contributions Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. License This project is licensed under the MIT License - see the LICENSE.md file for details
vitor Posted August 2, 2022 Posted August 2, 2022 Welcome @Artemy, 19 minutes ago, Artemy said: Project requires Python 3.8+ to run, which is not included by default with macOS. You can install Python 3 using this guide. That is not necessary. You are just calling python3, so if the user doesn’t have it macOS will try to run /usr/bin/python3 which will show a GUI prompt to install the Developer Tools (which is done anyway when installing Homebrew) and it will then just work on consecutive runs. The version macOS adds is 3.8.9.
Artemy Posted August 2, 2022 Author Posted August 2, 2022 21 minutes ago, vitor said: Welcome @Artemy, That is not necessary. You are just calling python3, so if the user doesn’t have it macOS will try to run /usr/bin/python3 which will show a GUI prompt to install the Developer Tools (which is done anyway when installing Homebrew) and it will then just work on consecutive runs. The version macOS adds is 3.8.9. thanks for the tip! I thought about this when I upgraded the workflow to Python 3, but found explaining the dependency requirement in this way more reliable and honest.
Artemy Posted August 2, 2022 Author Posted August 2, 2022 (edited) New version release: 3.0 Changelog: Update to Alfred 5 User Configuration This workflow version is for Alfred 5 and is not backwards compatible with Alfred 4.Alfred 4 users can use version 2.0 of the workflow. Thanks @vitor for the contribution Edited August 2, 2022 by Artemy vitor 1
Artemy Posted December 28, 2022 Author Posted December 28, 2022 (edited) New version release: 3.1 Changelog: Support stations with spaces in names For stations with spaces in names use `_` (underscore) instead of space inside the name, e.g. for trains between Den Haag Centraal and Utrecht Leidsche Rijn type `utrecht_leidsche_rijn den_haag_centraal` Download link Thanks to Github user @Cedrick84 for the contribution Edited December 28, 2022 by Artemy
vitor Posted December 28, 2022 Posted December 28, 2022 Wouldn’t it make sense to instead use a comma to separate station names always? As in: ns amsterdam, rotterdam and ns den haag centraal, utrecht leidsche rijn. Maybe names with spaces are rare enough that the underscore makes more sense, just pointing it out in case it wasn’t considered.
KorteAnton Posted January 4, 2023 Posted January 4, 2023 (edited) Hi, I like the idea of this Alfred Workflow but I don't get it to work. Which API key do I have to use? Here are the various APIs listed: https://apiportal.ns.nl/products I used the key of https://apiportal.ns.nl/products/NsApp but when I try the Alfred search, I get following error message: Can't parse server response. Am I using the key of the right NS product? Thanks Edited January 4, 2023 by KorteAnton
Artemy Posted January 4, 2023 Author Posted January 4, 2023 9 hours ago, KorteAnton said: Hi, I like the idea of this Alfred Workflow but I don't get it to work. Which API key do I have to use? Here are the various APIs listed: https://apiportal.ns.nl/products I used the key of https://apiportal.ns.nl/products/NsApp but when I try the Alfred search, I get following error message: Can't parse server response. Am I using the key of the right NS product? Thanks Hi KorteAnton! This is the correct product you're using. Can you please tell me more about how you use the API key? I've just tried to create a test account and use the newly generated API key and it seemed to work with no issues.
KorteAnton Posted January 5, 2023 Posted January 5, 2023 Hi, thanks for quick reply. I copied the primary API key from here: And then pasted it here: What did I miss?? Thanks!
KorteAnton Posted January 5, 2023 Posted January 5, 2023 The issue was caused by pasting the key incorrectly. Probably there was a line break in it. After pasting the key another time, the workflow works perfectly. Thanks Artemy 1
Artemy Posted January 5, 2023 Author Posted January 5, 2023 On 12/28/2022 at 8:59 PM, vitor said: Wouldn’t it make sense to instead use a comma to separate station names always? As in: ns amsterdam, rotterdam and ns den haag centraal, utrecht leidsche rijn. Maybe names with spaces are rare enough that the underscore makes more sense, just pointing it out in case it wasn’t considered. good point, thanks. I'll think about how to best implement this.
Artemy Posted July 6, 2024 Author Posted July 6, 2024 New version release: 4.0 Changelog: Use the stations information to autosuggest the origin and destination (#7) Add detailed instructions on how to obtain API Key (#6) Updated README This release is a breaking change in terms if UI/UX, please refer to the README for updated usage instructions Download link Thanks to Github user @MartinKanters for the contribution
Artemy Posted July 15, 2024 Author Posted July 15, 2024 New version release: 4.1 Changelog: Display available stations before typing (#9) Download link Thanks to @vitor for the suggestion
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now