Skip to content

Commit

Permalink
Update ID3 dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Marekkon5 committed Feb 23, 2024
1 parent de0710a commit bb1a012
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 58 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ test/
vc_redist.x64.exe
assets/vc_redist.x64.exe
crates/onetagger-python/pyembedded
*.dll
*.dll

perf.data
perf.data.old
flamegraph.svg
104 changes: 52 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/onetagger-autotag/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ impl AudioFileInfoImpl for AudioFileInfo {
// Parse filename
if (title.is_none() || artists.is_none()) && filename_template.is_some() {
let filename = path.as_ref().file_name().ok_or(anyhow!("Missing filename!"))?.to_str().ok_or(anyhow!("Missing filename"))?;

if let Some(captures) = filename_template.unwrap().captures(filename) {

// Title
if title.is_none() {
if let Some(m) = captures.name("title") {
Expand Down Expand Up @@ -490,9 +490,9 @@ impl AudioFileInfoImpl for AudioFileInfo {
let re = Regex::new("%[a-zA-Z0-9 ]+%").unwrap();
template = re.replace_all(&template, "(.+)").to_string();
// Extension
template = format!("{}\\.[a-zA-Z0-9]{{2,4}}$", template);
template = format!("{}\\.[a-zA-Z0-9]{{2,4}}$", template).trim().to_string();
// Final regex
Regex::new(template.trim()).ok()
Regex::new(&template).ok()
}

// Recognize on Shazam
Expand Down
4 changes: 2 additions & 2 deletions crates/onetagger-tag/src/id3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ID3Tag {
}
// AIFF
if ext == "aif" || ext == "aiff" {
let tag = Tag::read_from_aiff_path(path)?;
let tag = Tag::read_from_path(path)?;
let version = tag.version();
return Ok(ID3Tag {
tag,
Expand Down Expand Up @@ -220,7 +220,7 @@ impl TagImpl for ID3Tag {
.padding(2048)
.write_to_path(&self.tag, path)?;
},
ID3AudioFormat::AIFF => self.tag.write_to_aiff_path(path, version)?,
ID3AudioFormat::AIFF => self.tag.write_to_path(path, version)?,
ID3AudioFormat::WAV => crate::wav::write_wav(path, self.tag.clone(), version)?,
}

Expand Down

0 comments on commit bb1a012

Please sign in to comment.