Skip to content

Commit f1a947f

Browse files
authored
Merge pull request #22 from tsirysndr/fix/unknown-station
fix(ui): handle unknown station name and bitrate
2 parents d0b756b + f9fe43e commit f1a947f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/app.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ fn render_frame(state: Arc<Mutex<State>>, frame: &mut Frame) {
163163
);
164164
render_line(
165165
"Bitrate ",
166-
&format!("{} kbps", &state.br),
166+
&match state.br.is_empty() {
167+
true => "Unknown".to_string(),
168+
false => format!("{} kbps", &state.br),
169+
},
167170
Rect {
168171
x: size.x,
169172
y: match state.now_playing.is_empty() {

src/play.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub async fn exec(name_or_id: &str, provider: &str) -> Result<(), Error> {
5252
};
5353

5454
let mut app = App::new(&ui, &opts, frame_rx);
55+
let station_name = station.name.clone();
5556

5657
thread::spawn(move || {
5758
let client = reqwest::blocking::Client::new();
@@ -61,12 +62,15 @@ pub async fn exec(name_or_id: &str, provider: &str) -> Result<(), Error> {
6162
let headers = response.headers();
6263
cmd_tx
6364
.send(State {
64-
name: headers
65+
name: match headers
6566
.get("icy-name")
6667
.unwrap_or(&HeaderValue::from_static("Unknown"))
6768
.to_str()
6869
.unwrap()
69-
.to_string(),
70+
{
71+
"Unknown" => station_name,
72+
name => name.to_string(),
73+
},
7074
now_playing,
7175
genre: headers
7276
.get("icy-genre")

0 commit comments

Comments
 (0)