mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
24 lines
541 B
Rust
24 lines
541 B
Rust
|
const APRESOLVE_ENDPOINT : &'static str = "http://apresolve.spotify.com/";
|
||
|
|
||
|
use hyper;
|
||
|
use std::io::Read;
|
||
|
use rustc_serialize::json;
|
||
|
|
||
|
#[derive(RustcDecodable)]
|
||
|
pub struct APResolveData {
|
||
|
ap_list: Vec<String>
|
||
|
}
|
||
|
|
||
|
pub fn apresolve() -> Result<Vec<String>, ()> {
|
||
|
let client = hyper::client::Client::new();
|
||
|
let mut res = String::new();
|
||
|
|
||
|
client.get(APRESOLVE_ENDPOINT)
|
||
|
.send().unwrap()
|
||
|
.read_to_string(&mut res).unwrap();
|
||
|
|
||
|
let data : APResolveData = json::decode(&res).unwrap();
|
||
|
|
||
|
Ok(data.ap_list)
|
||
|
}
|