This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿ’„ Use progress bar for CueMarker synchroniser

+20 -1
+13 -1
src/synchronization/cue_markers.rs
··· 1 - use crate::synchronization::sync::Syncable; 1 + use crate::{synchronization::sync::Syncable, ui::MaybeProgressBar}; 2 2 use serde::Deserialize; 3 3 use serde_aux::field_attributes::deserialize_number_from_string; 4 4 use std::{collections::HashMap, io::Read, path::PathBuf, process::Stdio}; ··· 43 43 &self, 44 44 progress: Option<&indicatif::ProgressBar>, 45 45 ) -> super::sync::SyncData { 46 + progress.set_length(4); 47 + progress.set_message("Running ffprobe"); 48 + 46 49 let mut ffprobe = std::process::Command::new("ffprobe") 47 50 .args(["-v", "error"]) 48 51 .args(["-i", &self.path.to_string_lossy()]) ··· 54 57 "Couldn't run ffprobe to get chapters of {:?}", 55 58 self.path 56 59 )); 60 + 61 + progress.inc(1); 62 + progress.set_message("Getting ffprobe output"); 57 63 58 64 let mut raw_output = String::new(); 59 65 ffprobe ··· 63 69 .read_to_string(&mut raw_output) 64 70 .expect("Couldn't read ffprobe stdout"); 65 71 72 + progress.inc(1); 73 + progress.set_message("Parsing ffprobe output"); 74 + 66 75 let output: FFprobeOutput = 67 76 serde_json::from_str(&raw_output).expect("Invalid ffprobe output"); 77 + 78 + progress.inc(1); 79 + progress.set_message("Gathering chapters"); 68 80 69 81 super::sync::SyncData { 70 82 stems: HashMap::new(),
+7
src/ui.rs
··· 98 98 99 99 pub trait MaybeProgressBar<'a> { 100 100 fn set_message(&'a self, message: impl Into<Cow<'static, str>>); 101 + fn set_length(&'a self, length: u64); 101 102 fn inc(&'a self, n: u64); 102 103 fn println(&'a self, message: impl AsRef<str>); 103 104 } ··· 106 107 fn set_message(&'a self, message: impl Into<Cow<'static, str>>) { 107 108 if let Some(pb) = self { 108 109 pb.set_message(message); 110 + } 111 + } 112 + 113 + fn set_length(&'a self, length: u64) { 114 + if let Some(pb) = self { 115 + pb.set_length(length); 109 116 } 110 117 } 111 118