diff --git a/src/main.rs b/src/main.rs index e700cbb..8aa779c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,8 @@ struct Args { port: u16, #[arg(long, default_value_t = 300)] interval: u32, + #[arg(long, default_value = "Lettestr")] + station: String, } @@ -53,7 +55,7 @@ async fn main() -> Result<(), Box> { //FIXME Set last_request initially to 1 hour before now let mut last_request = Instant::now() - Duration::from_secs(3600); let interval = Duration::from_secs(args.interval as u64); - let station_id = tokio::task::spawn_blocking(|| straba::lookup_station_id("Lettestr")) + let station_id = tokio::task::spawn_blocking(move || straba::lookup_station_id(&args.station)) .await .unwrap() .expect("Failed to lookup station ID"); diff --git a/src/straba.rs b/src/straba.rs index ebd05b8..240a8f5 100644 --- a/src/straba.rs +++ b/src/straba.rs @@ -214,6 +214,17 @@ pub fn fetch_data(station_id: u64, debug_print: Option) -> NextDeparture { return_value.inbound_station = stop.destination_label; return_value.inbound_diff = diff; } + } else if stop.destination_label.contains("Mannheim") { + if diff < return_value.inbound_diff { + return_value.inbound_station = stop.destination_label; + return_value.inbound_diff = diff; + } + } else { + // Unkown stations are declared as outbound + if diff < return_value.outbound_diff { + return_value.outbound_station = stop.destination_label; + return_value.outbound_diff = diff; + } } } else { println!(