2016-03-13 20:03:09 +00:00
|
|
|
const APRESOLVE_ENDPOINT : &'static str = "http://apresolve.spotify.com/";
|
|
|
|
|
|
|
|
use hyper;
|
|
|
|
use std::io::Read;
|
2016-07-06 01:29:38 +00:00
|
|
|
use serde_json;
|
2016-03-13 20:03:09 +00:00
|
|
|
|
2016-07-06 01:29:38 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2016-03-13 20:03:09 +00:00
|
|
|
pub struct APResolveData {
|
|
|
|
ap_list: Vec<String>
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn apresolve() -> Result<Vec<String>, ()> {
|
|
|
|
let client = hyper::client::Client::new();
|
|
|
|
|
2016-03-16 00:05:05 +00:00
|
|
|
let mut response = client.get(APRESOLVE_ENDPOINT).send().unwrap();
|
|
|
|
let mut data = String::new();
|
|
|
|
response.read_to_string(&mut data).unwrap();
|
2016-03-13 20:03:09 +00:00
|
|
|
|
2016-07-06 01:29:38 +00:00
|
|
|
let data : APResolveData = serde_json::from_str(&data).unwrap();
|
2016-03-13 20:03:09 +00:00
|
|
|
|
|
|
|
Ok(data.ap_list)
|
|
|
|
}
|