Browse and listen to thousands of radio stations across the globe right from your terminal ๐ ๐ป ๐ตโจ
radio
rust
tokio
web-radio
command-line-tool
tui
1use std::net::SocketAddr;
2
3use anyhow::Error;
4use owo_colors::OwoColorize;
5use tonic::transport::Server;
6use tunein_cli::api::tunein::v1alpha1::{
7 browse_service_server::BrowseServiceServer, playback_service_server::PlaybackServiceServer,
8};
9use tunein_cli::api::tunein::FILE_DESCRIPTOR_SET;
10
11use self::{browse::Browse, playback::Playback};
12
13pub mod browse;
14pub mod playback;
15
16pub async fn exec(port: u16) -> Result<(), Error> {
17 let addr: SocketAddr = format!("0.0.0.0:{}", port).parse().unwrap();
18 println!(
19 "{}",
20 r#"
21 ______ ____ _______ ____
22 /_ __/_ _____ ___ / _/__ / ___/ / / _/
23 / / / // / _ \/ -_)/ // _ \ / /__/ /___/ /
24 /_/ \_,_/_//_/\__/___/_//_/ \___/____/___/
25
26 "#
27 .bright_green()
28 );
29 println!("Listening on {}", addr.cyan());
30 Server::builder()
31 .accept_http1(true)
32 .add_service(
33 tonic_reflection::server::Builder::configure()
34 .register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET)
35 .build_v1alpha()?,
36 )
37 .add_service(tonic_web::enable(BrowseServiceServer::new(
38 Browse::default(),
39 )))
40 .add_service(tonic_web::enable(PlaybackServiceServer::new(
41 Playback::default(),
42 )))
43 .serve(addr)
44 .await?;
45 Ok(())
46}