Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim the beginning of output line for newer versions of ytarchive #38

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading