mirror of
https://gitlab.com/hladislav/radiobrowser-lib-rust.git
synced 2025-04-29 23:34:12 +00:00
station list changes
This commit is contained in:
parent
68acb8593b
commit
62b1ca0a96
5 changed files with 22 additions and 4 deletions
|
@ -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"]
|
||||
|
|
|
@ -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<String>) -> Result<Vec<ApiStationHistory>, Box<dyn Error>> {
|
||||
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<ApiConfig, Box<dyn Error>> {
|
||||
Ok(self.post_api("/json/config").await?)
|
||||
}
|
||||
|
|
|
@ -35,5 +35,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
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(())
|
||||
}
|
||||
|
|
|
@ -19,5 +19,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
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(())
|
||||
}
|
||||
|
|
|
@ -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<String>) -> Result<Vec<ApiStationHistory>, Box<dyn Error>> {
|
||||
task::block_on(async { self.api.get_station_changes(limit, last_change_uuid).await })
|
||||
}
|
||||
|
||||
pub fn get_server_config(&mut self) -> Result<ApiConfig, Box<dyn Error>> {
|
||||
task::block_on(async { self.api.get_server_config().await })
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue