apresolve.rs 574 B

12345678910111213141516171819202122
  1. const APRESOLVE_ENDPOINT : &'static str = "http://apresolve.spotify.com/";
  2. use hyper;
  3. use std::io::Read;
  4. use serde_json;
  5. #[derive(Clone, Debug, Serialize, Deserialize)]
  6. pub struct APResolveData {
  7. ap_list: Vec<String>
  8. }
  9. pub fn apresolve() -> Result<Vec<String>, ()> {
  10. let client = hyper::client::Client::new();
  11. let mut response = client.get(APRESOLVE_ENDPOINT).send().unwrap();
  12. let mut data = String::new();
  13. response.read_to_string(&mut data).unwrap();
  14. let data : APResolveData = serde_json::from_str(&data).unwrap();
  15. Ok(data.ap_list)
  16. }