From 0a5757e76a731eaac67f87b62f3dc218fc471222 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 14 Jun 2024 10:38:43 +0200 Subject: Bump icy-metadata to v0.1.1 and some debugging --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/audio/rodio.rs | 27 +++++++++++++-------------- src/main.rs | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fd9568..ca0db0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -624,9 +624,9 @@ dependencies = [ [[package]] name = "icy-metadata" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473e3fafde6c9b9d0753315701d000317db6965085bafcf7369c8d945dd5ef3b" +checksum = "4a53b5be13ffaacfc452a3406d0182298a3b367d624422bb5a7c18c50b1fe16b" dependencies = [ "http", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 53301d9..72ce3c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["radio", "somafm", "media"] repository = "https://github.com/yuvadm/somafm.rs" [dependencies] -icy-metadata = { version = "0.1.0" } +icy-metadata = { version = "0.1.1" } inquire = "0.7.5" reqwest = { version = "0.12.4", features = ["blocking"] } rodio = { version = "0.18.1", features = ["symphonia", "symphonia-mp3"] } diff --git a/src/audio/rodio.rs b/src/audio/rodio.rs index 0f9fbb2..49ebe40 100644 --- a/src/audio/rodio.rs +++ b/src/audio/rodio.rs @@ -42,23 +42,22 @@ impl Rodio { .await .unwrap(); - sink.append( - Decoder::new(IcyMetadataReader::new( - reader, - // Since we requested icy metadata, the metadata interval header should be present in the - // response. This will allow us to parse the metadata within the stream - icy_headers.metadata_interval(), - |metadata| { - if let Ok(md) = metadata { - if let Some(tr) = md.stream_title() { - println!(" {tr}"); - } + let metadata_reader = IcyMetadataReader::new( + reader, + // Since we requested icy metadata, the metadata interval header should be present in the + // response. This will allow us to parse the metadata within the stream + icy_headers.metadata_interval(), + |metadata| { + if let Ok(md) = metadata { + if let Some(tr) = md.stream_title() { + println!(" {tr}"); } - }, - )) - .unwrap(), + } + }, ); + sink.append(Decoder::new(metadata_reader).unwrap()); + let handle = tokio::task::spawn_blocking(move || { sink.sleep_until_end(); }); diff --git a/src/main.rs b/src/main.rs index 10c7d6f..5303421 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ async fn main() { let url = get_stream_url(&playlist).await.unwrap(); sp.stop_with_newline(); - let _sp = Spinner::new(Spinners::Arrow3, format!("Playing {}", ch.title)); + let _sp = Spinner::new(Spinners::Arrow3, format!("Playing {} at {}", ch.title, url)); audio::get_backend().play(&url).await } Err(_e) => { -- cgit v1.3.1