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