You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.4 KiB
75 lines
2.4 KiB
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
|
#[allow(dead_code)]
|
|
|
|
pub use crate::player::Player;
|
|
pub use crate::app::App;
|
|
|
|
use std::{thread, io, fs, time};
|
|
use libtor::{Tor, TorFlag, Error as libtorError, log as libtorLog};
|
|
#[allow(unused_imports)]
|
|
use rodio::{Decoder, OutputStream, source::Source, Sink};
|
|
|
|
mod app;
|
|
mod player;
|
|
|
|
|
|
// "http://wowradiod6mhb4ignjqy5ghf5l42yh2yeumgeq3yi7gn7yqy3efhe5ad.onion"
|
|
// "http://wowradiof5wx62w4avdk5fwbvcoea2z4ul2q3awffn5vmfaa3vhlgiid.onion"
|
|
// "http://radio.poysibicsj73uhw7sjrv3fyopoyulrns4nlr5amyqdtafkqzlocd4qad.onion"
|
|
// "http://anonyradixhkgh5myfrkarggfnmdzzhhcgoy2v66uf7sml27to5n2tid.onion"
|
|
// "http://u2frppcgwqmoca7h3hu5l72upkwhcf2n6umrkqsnvnpahjynkre6sqyd.onion:8300/radio"
|
|
// "https://radio.wownero.com/wow.ogg"
|
|
|
|
const TOR_LOG: &str = &"/tmp/tor-rust/tor.log";
|
|
const RADIO_STREAM: &str = &"radio.ogg";
|
|
|
|
fn cleanup() {
|
|
let r: io::Result<()> = fs::remove_file(&RADIO_STREAM);
|
|
match r {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
fn start_tor() -> thread::JoinHandle<Result<u8, libtorError>> {
|
|
let t: thread::JoinHandle<_> = Tor::new()
|
|
.flag(TorFlag::DataDirectory("/tmp/tor-rust".into()))
|
|
.flag(TorFlag::SocksPort(19050))
|
|
.flag(TorFlag::LogTo(libtorLog::LogLevel::Info, libtorLog::LogDestination::File(TOR_LOG.to_string())))
|
|
.start_background();
|
|
return t
|
|
}
|
|
|
|
fn clear_tor_log() -> io::Result<()> {
|
|
let r: io::Result<()> = fs::write(TOR_LOG, "");
|
|
return r
|
|
}
|
|
|
|
fn get_wow_price() -> String {
|
|
let url: &str = "https://tradeogre.com/api/v1/ticker/BTC-WOW";
|
|
let client: reqwest::blocking::Client = reqwest::blocking::ClientBuilder::new()
|
|
.timeout(time::Duration::from_secs(10))
|
|
.build()
|
|
.unwrap();
|
|
let res: String = client.get(url)
|
|
.send()
|
|
.unwrap()
|
|
.text()
|
|
.unwrap();
|
|
return res
|
|
}
|
|
|
|
fn main() {
|
|
let (_stream, stream_handle) = rodio::OutputStream::try_default().unwrap();
|
|
let sink: rodio::Sink = rodio::Sink::try_new(&stream_handle).unwrap();
|
|
let player: player::Player = player::Player::new(sink, stream_handle);
|
|
let mut app: app::App = app::App::default();
|
|
app.player = player;
|
|
let options: eframe::NativeOptions = eframe::NativeOptions::default();
|
|
eframe::run_native(
|
|
"lza gui",
|
|
options,
|
|
Box::new(|_cc| Box::new(app)),
|
|
);
|
|
let _ = cleanup();
|
|
}
|