@ -16,7 +16,7 @@ impl Player {
sink ,
stream_handle ,
stream_thread : std ::thread ::spawn ( | | { } ) ,
stream_source : "http ://wowradiod6mhb4ignjqy5ghf5l42yh2yeumgeq3yi7gn7yqy3efhe5ad.onion ". to_owned ( ) ,
stream_source : "http s://radio.wownero.com/wow.ogg ". to_owned ( ) ,
stream_exif : "" . to_owned ( ) ,
volume : 100.0 ,
playing : false
@ -30,31 +30,20 @@ impl Player {
}
pub fn check_radio_stream ( & self ) -> bool {
let url = format! ( "{}/wow.ogg" , self . stream_source ) ;
let res = reqwest ::blocking ::Client ::builder ( )
. proxy ( reqwest ::Proxy ::http ( "socks5://127.0.0.1:19050" ) . unwrap ( ) )
. build ( )
. unwrap ( )
. get ( url )
. send ( ) ;
match res {
Ok ( r ) = > r . status ( ) . is_success ( ) ,
Err ( _e ) = > false
let res : reqwest ::blocking ::Response = reqwest ::blocking ::get ( self . stream_source . clone ( ) ) . expect ( "request failed" ) ;
if res . status ( ) . is_success ( ) {
true
} else {
false
}
}
pub fn start_radio_stream ( & self ) -> std ::thread ::JoinHandle < ( ) > {
let url = format! ( "{}/wow.ogg" , self . stream_source ) ;
let url = self . stream_source . clone ( ) ;
let t : Result < std ::thread ::JoinHandle < ( ) > , std ::io ::Error > = std ::thread ::Builder ::new ( ) . name ( "radio_stream" . to_string ( ) ) . spawn ( move | | {
let res : Result < reqwest ::blocking ::Response , reqwest ::Error > = reqwest ::blocking ::Client ::builder ( )
. proxy ( reqwest ::Proxy ::http ( "socks5://127.0.0.1:19050" ) . unwrap ( ) )
. timeout ( std ::time ::Duration ::from_secs ( 15 ) )
. build ( )
. unwrap ( )
. get ( url )
. send ( ) ;
let mut res : reqwest ::blocking ::Response = reqwest ::blocking ::get ( url ) . expect ( "request failed" ) ;
let mut out : std ::fs ::File = std ::fs ::File ::create ( & crate ::RADIO_STREAM ) . expect ( "failed to create file" ) ;
std ::io ::copy ( & mut res .unwrap ( ) , & mut out ) . expect ( "failed to copy content" ) ;
std ::io ::copy ( & mut res , & mut out ) . expect ( "failed to copy content" ) ;
} ) ;
return t . unwrap ( )
}