radiobrowser-lib-rust/examples/test.rs

35 lines
1.3 KiB
Rust
Raw Normal View History

2023-10-20 19:07:41 +00:00
use radiobrowser::{blocking::RadioBrowserAPI, RbError};
2022-04-26 20:26:46 +00:00
2023-10-20 19:07:41 +00:00
fn main() -> Result<(), RbError> {
2022-05-06 21:18:52 +00:00
let mut api = RadioBrowserAPI::new()?;
2023-01-27 23:09:01 +00:00
let servers = RadioBrowserAPI::get_default_servers()?;
2022-04-26 20:26:46 +00:00
println!("Servers: {:?}", servers);
2022-05-06 21:18:52 +00:00
let status = api.get_server_status()?;
println!("Status: {:#?}", status);
let config = api.get_server_config()?;
println!("Config: {:#?}", config);
2022-04-26 20:26:46 +00:00
let countries = api.get_countries().send()?;
2022-05-06 21:18:52 +00:00
println!("Countries: {:?}", countries.len());
let tags = vec!["jazz", "classical"];
2022-05-12 20:42:44 +00:00
let stations = api.get_stations().tag_list(tags).send()?;
println!(
"Stations with tags containing 'jazz' and 'classical': {:?}",
stations.len()
);
println!(
"First found station: {:#?}",
stations[0].clicktimestamp_iso8601
);
println!(
"First station JSON: {}",
serde_json::to_string(&stations[0]).expect("Failure")
);
2022-05-06 21:18:52 +00:00
let vote_result = api.station_vote(&stations[0].stationuuid)?;
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)?;
2023-01-27 22:43:42 +00:00
println!("Station changes result: {:#?}", station_changes);
2022-04-26 20:26:46 +00:00
Ok(())
2022-05-06 21:18:52 +00:00
}