Skip to content

Commit

Permalink
Trim the beginning of output line for newer versions of ytarchive (#38)
Browse files Browse the repository at this point in the history
* trim the beginning of yta output line for all versions

* run cargo fmt

* wrap the regex for detecting timestamp with lazy_static!
  • Loading branch information
1toldyou authored Apr 19, 2024
1 parent b1b0b42 commit 589ef77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea

/target

config.toml
11 changes: 7 additions & 4 deletions src/module/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,13 @@ impl YTAStatus {
}

// New versions of ytarchive prepend a timestamp to the output
let line = if self.version == Some("0.3.2".into())
&& line.len() > 20
&& line.chars().nth(4) == Some('/')
{
// Sample line
// 2024/04/16 16:25:31
lazy_static! {
static ref TIMESTAMP_RE: Regex = Regex::new(r"^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}")
.expect("Failed to compile regex for detecting yta output timestamp");
}
let line = if line.len() > 20 && TIMESTAMP_RE.is_match(line) {
line[20..].trim()
} else {
line
Expand Down

0 comments on commit 589ef77

Please sign in to comment.