summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/main.rs b/src/main.rs
index 78081a4..e06981e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,5 @@
use std::{env, fs::{self, File}, path::Path, io::{Error, BufReader, Read}, fmt::format, os::fd::IntoRawFd};
-
use lofty::{Probe, TaggedFileExt, LoftyError, TagExt, Tag, Picture, Accessor, PictureType};
-
use clap::Parser;
#[derive(Parser, Debug)]
@@ -17,12 +15,12 @@ struct Args {
}
/*
- Title
- Artist - Title
- Artist - Album - Title
- Artist - Album - Nr - Title
- Artist - Album - Nr - Max Nr - Title
- */
+ Title
+ Artist - Title
+ Artist - Album - Title
+ Artist - Album - Nr - Title
+ Artist - Album - Nr - Max Nr - Title
+ */
struct InnerTag {
title: String,
@@ -114,25 +112,25 @@ fn truncate(s: &str, min_chars: usize, max_chars: usize) -> &str {
}
fn tag_ogg_file(path: &Path) -> Result<(), LoftyError> {
- let mut tagged_file = Probe::open(path)
- .expect("ERROR: Bad path provided!")
- .read()?;
-
- let tag = match tagged_file.primary_tag_mut() {
- Some(primary_tag) => primary_tag,
- None => {
- if let Some(first_tag) = tagged_file.first_tag_mut() {
- first_tag
- } else {
- let tag_type = tagged_file.primary_tag_type();
-
- eprintln!("👻 No tags found, creating a new tag of type `{tag_type:?}`");
- tagged_file.insert_tag(Tag::new(tag_type));
-
- tagged_file.primary_tag_mut().unwrap()
- }
- },
- };
+ let mut tagged_file = Probe::open(path)
+ .expect("ERROR: Bad path provided!")
+ .read()?;
+
+ let tag = match tagged_file.primary_tag_mut() {
+ Some(primary_tag) => primary_tag,
+ None => {
+ if let Some(first_tag) = tagged_file.first_tag_mut() {
+ first_tag
+ } else {
+ let tag_type = tagged_file.primary_tag_type();
+
+ eprintln!("👻 No tags found, creating a new tag of type `{tag_type:?}`");
+ tagged_file.insert_tag(Tag::new(tag_type));
+
+ tagged_file.primary_tag_mut().unwrap()
+ }
+ },
+ };
let path_without_ext = path.with_extension("");
let name = path_without_ext.file_name().unwrap().to_str().unwrap();
Software created with 💖