Added ability to specify how many results will be returned

This commit is contained in:
genuineparts 2024-11-04 08:47:56 +01:00
parent f72afb66e5
commit f1237e0dc4
3 changed files with 29 additions and 15 deletions

View file

@ -24,10 +24,10 @@ public class OebbCheck {
>0 is the delay in Minutes
9999 means the Train has been cancelled
*/
public int getStatus(String Station, String Time, String FinalStop, String TrainType) throws IOException {
public int getStatus(String Station, String Time, String FinalStop, String TrainType, String maxjourneys) throws IOException {
JSONArray journeys;
try {
journeys = getData(Station, Time);
journeys = getData(Station, Time, maxjourneys);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
@ -48,8 +48,8 @@ public class OebbCheck {
return -1;
}
private static JSONArray getData(String Station, String Time) throws IOException, URISyntaxException {
URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=1&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL();
private static JSONArray getData(String Station, String Time, String maxjourneys) throws IOException, URISyntaxException {
URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=" + maxjourneys + "&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL();
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(