From 62b1ca0a96d9e036d2b9ac3ce7ffc581fb742bea Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 27 Jan 2023 23:43:42 +0100 Subject: [PATCH] station list changes --- Cargo.toml | 8 ++++---- src/api.rs | 9 +++++++++ src/bin/test-async.rs | 2 ++ src/bin/test.rs | 2 ++ src/blocking/api.rs | 5 +++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c62407..6b4f3c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,12 +14,12 @@ repository = "https://gitlab.com/radiobrowser/radiobrowser-lib-rust" [dependencies] async-std = { version = "1.12.0", features = ["attributes", "tokio1"] } async-std-resolver = "0.22.0" -chrono = { version = "0.4.22", features = ["serde"], optional = true } -futures = { version = "0.3.24" } +chrono = { version = "0.4.23", features = ["serde"], optional = true } +futures = { version = "0.3.25" } log = { version = "0.4.17" } rand = { version = "0.8.5" } -reqwest = { version = "0.11.11", features = ["json"] } -serde = { version = "1.0.144", features = ["derive"] } +reqwest = { version = "0.11.14", features = ["json"] } +serde = { version = "1.0.152", features = ["derive"] } [features] default = ["chrono", "blocking"] diff --git a/src/api.rs b/src/api.rs index 4dacf3f..6deb1d7 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,4 +1,5 @@ use crate::ApiStationClickResult; +use crate::ApiStationHistory; use crate::ApiStationVoteResult; use crate::ApiStatus; use crate::external::post_api; @@ -69,6 +70,14 @@ impl RadioBrowserAPI { post_api(self.get_current_server(), endpoint.as_ref(), mapjson).await } + pub async fn get_station_changes(&mut self, limit: u64, last_change_uuid: Option) -> Result, Box> { + let query = match last_change_uuid { + Some(uuid) => format!("/json/stations/changed?limit={}&lastchangeuuid={}", limit, uuid), + None => format!("/json/stations/changed?limit={}", limit) + }; + Ok(self.post_api(query).await?) + } + pub async fn get_server_config(&mut self) -> Result> { Ok(self.post_api("/json/config").await?) } diff --git a/src/bin/test-async.rs b/src/bin/test-async.rs index 64e8f89..62b6adb 100644 --- a/src/bin/test-async.rs +++ b/src/bin/test-async.rs @@ -35,5 +35,7 @@ async fn main() -> Result<(), Box> { println!("Stations voted result: {:?}", vote_result); let click_result = api.station_click(&stations[0].stationuuid).await?; println!("Stations clicked result: {:?}", click_result); + let station_changes = api.get_station_changes(1,None).await?; + println!("Station changes result: {:#?}", station_changes); Ok(()) } diff --git a/src/bin/test.rs b/src/bin/test.rs index 19336a1..0baf42d 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -19,5 +19,7 @@ fn main() -> Result<(), Box> { println!("Stations voted result: {:?}", vote_result); let click_result = api.station_click(&stations[0].stationuuid)?; println!("Stations clicked result: {:?}", click_result); + let station_changes = api.get_station_changes(1,None)?; + println!("Station changes result: {:#?}", station_changes); Ok(()) } diff --git a/src/blocking/api.rs b/src/blocking/api.rs index 00fee64..4d54229 100644 --- a/src/blocking/api.rs +++ b/src/blocking/api.rs @@ -1,3 +1,4 @@ +use crate::ApiStationHistory; use crate::blocking::stationsearchbuilder::StationSearchBuilder; use crate::blocking::CountrySearchBuilder; use crate::blocking::LanguageSearchBuilder; @@ -28,6 +29,10 @@ impl RadioBrowserAPI { task::block_on(async { self.api.get_server_status().await }) } + pub fn get_station_changes(&mut self, limit: u64, last_change_uuid: Option) -> Result, Box> { + task::block_on(async { self.api.get_station_changes(limit, last_change_uuid).await }) + } + pub fn get_server_config(&mut self) -> Result> { task::block_on(async { self.api.get_server_config().await }) }