fix break when missing enstimate time

This commit is contained in:
djkato 2024-12-23 23:24:52 +01:00
parent 000596424f
commit d927d7811a
3 changed files with 13 additions and 6 deletions

4
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "addr2line" name = "addr2line"
@ -252,7 +252,7 @@ dependencies = [
[[package]] [[package]]
name = "n-mb" name = "n-mb"
version = "1.1.1" version = "1.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",

View file

@ -1,7 +1,7 @@
[package] [package]
name = "n-mb" name = "n-mb"
authors = ["Djkáťo <djkatovfx@gmail.com>"] authors = ["Djkáťo <djkatovfx@gmail.com>"]
version = "1.1.2" version = "1.1.3"
edition = "2021" edition = "2021"
description = "Simple ffmpeg wrapper to parse files to the most efficient formats within a set size" description = "Simple ffmpeg wrapper to parse files to the most efficient formats within a set size"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -150,13 +150,14 @@ async fn main() -> anyhow::Result<()> {
use std::time::Duration; use std::time::Duration;
use tokio::time::interval; use tokio::time::interval;
let commands_ref = commands.clone(); 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 { command_spawns.push(tokio::spawn(async move {
intv.tick().await; intv.tick().await;
'line: while let Ok(Some(line)) = buff_reader.1.next_line().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=") { if let Some(time_start) = line.find("out_time=") {
let time: Vec<String> = line[time_start + 10..] let time: Vec<String> = line[time_start + 10..]
.split(':') .split(':')
@ -169,9 +170,13 @@ async fn main() -> anyhow::Result<()> {
if let Ok(number) = part.parse::<f32>() { if let Ok(number) = part.parse::<f32>() {
parsed_time.push(number) parsed_time.push(number)
} else { } 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 time = parsed_time[0] * 3600. + parsed_time[1] * 60. + parsed_time[2];
let mut command = commands_ref.lock().await; let mut command = commands_ref.lock().await;
@ -181,6 +186,8 @@ async fn main() -> anyhow::Result<()> {
command.progressed_time = time; command.progressed_time = time;
} }
if let Some(progress_i) = line.find("progress=") { 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 mut command = commands_ref.lock().await;
let command = command.get_mut(buff_reader.0).unwrap(); let command = command.get_mut(buff_reader.0).unwrap();