summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-06-14 10:38:43 +0200
committerYuval Adam <_@yuv.al>2024-06-14 10:38:43 +0200
commit0a5757e76a731eaac67f87b62f3dc218fc471222 (patch)
tree7299da8b3e982d3ad1471d33350f79f990a29f36
parent482a942cd9e62fadee4ee7bc1fd7e8def8a85f71 (diff)
Bump icy-metadata to v0.1.1 and some debugging
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--src/audio/rodio.rs27
-rw-r--r--src/main.rs2
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) => {