librespot/discovery/examples/discovery.rs
Roderick van Domburg 39bf40bcc7
Lay groundwork for new Spotify API client (#805)
Lay groundwork for new Spotify API before removing `spirc`

* Add token provider
* Introduce HTTP client
* Introduce caching `ApResolver` component
* Remove `keymaster` and update example
* Use `PacketType` instead of hex identifiers
* Document new unknown packet 0xb6
2021-06-28 20:58:58 +02:00

25 lines
644 B
Rust

use futures::StreamExt;
use librespot_discovery::DeviceType;
use sha1::{Digest, Sha1};
use simple_logger::SimpleLogger;
#[tokio::main(flavor = "current_thread")]
async fn main() {
SimpleLogger::new()
.with_level(log::LevelFilter::Debug)
.init()
.unwrap();
let name = "Librespot";
let device_id = hex::encode(Sha1::digest(name.as_bytes()));
let mut server = librespot_discovery::Discovery::builder(device_id)
.name(name)
.device_type(DeviceType::Computer)
.launch()
.unwrap();
while let Some(x) = server.next().await {
println!("Received {:?}", x);
}
}