Browse and listen to thousands of radio stations across the globe right from your terminal ๐ŸŒŽ ๐Ÿ“ป ๐ŸŽตโœจ
radio rust tokio web-radio command-line-tool tui

Merge pull request #22 from tsirysndr/fix/unknown-station

fix(ui): handle unknown station name and bitrate

authored by tsiry-sandratraina.com and committed by

GitHub f1a947fa d0b756ba

+10 -3
+4 -1
src/app.rs
··· 163 163 ); 164 164 render_line( 165 165 "Bitrate ", 166 - &format!("{} kbps", &state.br), 166 + &match state.br.is_empty() { 167 + true => "Unknown".to_string(), 168 + false => format!("{} kbps", &state.br), 169 + }, 167 170 Rect { 168 171 x: size.x, 169 172 y: match state.now_playing.is_empty() {
+6 -2
src/play.rs
··· 52 52 }; 53 53 54 54 let mut app = App::new(&ui, &opts, frame_rx); 55 + let station_name = station.name.clone(); 55 56 56 57 thread::spawn(move || { 57 58 let client = reqwest::blocking::Client::new(); ··· 61 62 let headers = response.headers(); 62 63 cmd_tx 63 64 .send(State { 64 - name: headers 65 + name: match headers 65 66 .get("icy-name") 66 67 .unwrap_or(&HeaderValue::from_static("Unknown")) 67 68 .to_str() 68 69 .unwrap() 69 - .to_string(), 70 + { 71 + "Unknown" => station_name, 72 + name => name.to_string(), 73 + }, 70 74 now_playing, 71 75 genre: headers 72 76 .get("icy-genre")