fix break when missing enstimate time
This commit is contained in:
parent
000596424f
commit
d927d7811a
3 changed files with 13 additions and 6 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
|
@ -252,7 +252,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "n-mb"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "n-mb"
|
||||
authors = ["Djkáťo <djkatovfx@gmail.com>"]
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
edition = "2021"
|
||||
description = "Simple ffmpeg wrapper to parse files to the most efficient formats within a set size"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -150,13 +150,14 @@ async fn main() -> anyhow::Result<()> {
|
|||
use std::time::Duration;
|
||||
use tokio::time::interval;
|
||||
let commands_ref = commands.clone();
|
||||
let mut intv = interval(Duration::from_millis(50));
|
||||
let mut intv = interval(Duration::from_millis(10));
|
||||
|
||||
command_spawns.push(tokio::spawn(async move {
|
||||
intv.tick().await;
|
||||
|
||||
'line: while let Ok(Some(line)) = buff_reader.1.next_line().await {
|
||||
// dbg!(&line);
|
||||
#[cfg(debug_assertions)]
|
||||
dbg!(&line);
|
||||
if let Some(time_start) = line.find("out_time=") {
|
||||
let time: Vec<String> = line[time_start + 10..]
|
||||
.split(':')
|
||||
|
@ -169,9 +170,13 @@ async fn main() -> anyhow::Result<()> {
|
|||
if let Ok(number) = part.parse::<f32>() {
|
||||
parsed_time.push(number)
|
||||
} else {
|
||||
break 'line;
|
||||
// parsed_time.push(0.);
|
||||
// break 'line;
|
||||
}
|
||||
}
|
||||
if parsed_time.len() == 0 {
|
||||
parsed_time.append(&mut vec![0., 0., 0.]);
|
||||
}
|
||||
let time = parsed_time[0] * 3600. + parsed_time[1] * 60. + parsed_time[2];
|
||||
|
||||
let mut command = commands_ref.lock().await;
|
||||
|
@ -181,6 +186,8 @@ async fn main() -> anyhow::Result<()> {
|
|||
command.progressed_time = time;
|
||||
}
|
||||
if let Some(progress_i) = line.find("progress=") {
|
||||
#[cfg(debug_assertions)]
|
||||
println!("found progress!, {}", &line[progress_i + 9..]);
|
||||
let mut command = commands_ref.lock().await;
|
||||
let command = command.get_mut(buff_reader.0).unwrap();
|
||||
|
||||
|
|
Loading…
Reference in a new issue