Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubelotix committed Jul 17, 2020
1 parent 52c71c2 commit dde1eea
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl From<gleam_finder::gleam::Giveaway> for Giveaway {
#[tokio::main]
async fn main() {
let matches = App::new("Gleam finder")
.version("3.1")
.version("3.2")
.author("Mubelotix <mubelotix@gmail.com>")
.about("Search for gleam.io links on the web.")
.arg(
Expand Down Expand Up @@ -245,8 +245,7 @@ async fn main() {

let mut progress_bar = ProgressBar::new(7);
progress_bar.set_action("Searching", Color::White, Style::Normal);

/*let mut results = Vec::new();
let mut results = Vec::new();
let mut page = 0;
loop {
progress_bar.set_action("Loading", Color::Blue, Style::Normal);
Expand All @@ -262,6 +261,10 @@ async fn main() {
break;
}
}
progress_bar.set_action("Finished", Color::Green, Style::Bold);
progress_bar.print_info("Finished", &format!("{} results found", results.len()), Color::Green, Style::Bold);
progress_bar.finalize();
println!();

let mut progress_bar = ProgressBar::new(results.len());
let mut timeout_check = HashMap::new();
Expand All @@ -282,7 +285,11 @@ async fn main() {
}

progress_bar.set_action("Loading", Color::Blue, Style::Normal);
for gleam_link in intermediary::resolve(results[link_idx].get_url()).unwrap_or_default() {
let giveaway_urls = intermediary::resolve(results[link_idx].get_url()).unwrap_or_default();
if giveaway_urls.is_empty() {
progress_bar.print_info("Useless", &format!("page loaded: {}", results[link_idx].get_url()), Color::Yellow, Style::Normal);
}
for gleam_link in giveaway_urls {
if advanced {
if force_cooldown {
progress_bar.set_action("Sleeping", Color::Yellow, Style::Normal);
Expand All @@ -309,7 +316,11 @@ async fn main() {

progress_bar.inc();
timeout_check.insert(results[link_idx].get_host(), Instant::now());
}*/
}
progress_bar.set_action("Finished", Color::Green, Style::Bold);
progress_bar.print_info("Finished", &format!("{} giveaways found", giveaways.len()), Color::Green, Style::Bold);
progress_bar.finalize();
println!();

if save {
match File::open("giveaways.json") {
Expand Down Expand Up @@ -356,8 +367,10 @@ async fn main() {
progress_bar.inc();
thread::sleep(Duration::from_secs(cooldown));
}
progress_bar.print_info("Finished", &format!("{} giveaways updated", len), Color::Green, Style::Bold);
progress_bar.set_action("Finished", Color::Green, Style::Bold);
progress_bar.finalize();
println!();
}

match File::create("giveaways.json") {
Expand Down Expand Up @@ -404,7 +417,7 @@ async fn main() {

if loop_enabled {
let time_elapsed = Instant::now().duration_since(start);
let time_to_sleep = Duration::from_secs(3600) - time_elapsed;
let time_to_sleep = Duration::from_secs(3540) - time_elapsed;
thread::sleep(time_to_sleep);
} else {
break;
Expand Down

0 comments on commit dde1eea

Please sign in to comment.