mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-13 22:22:31 +00:00
Fix extensions
This commit is contained in:
parent
cdc6a33298
commit
97253ef487
3 changed files with 16 additions and 16 deletions
|
@ -39,20 +39,6 @@ where
|
|||
pub(crate) fn parse_id3v1(reader: [u8; 128]) -> Tag {
|
||||
let mut tag = Tag::new(TagType::Id3v1);
|
||||
|
||||
fn decode_text(key: ItemKey, data: &[u8]) -> Option<TagItem> {
|
||||
let read = data
|
||||
.iter()
|
||||
.filter(|c| **c > 0x1f)
|
||||
.map(|c| *c as char)
|
||||
.collect::<String>();
|
||||
|
||||
if read.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(TagItem::new(key, ItemValue::Text(read)))
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(title) = decode_text(ItemKey::Title, &reader[3..33]) {
|
||||
tag.insert_item(title);
|
||||
}
|
||||
|
@ -92,3 +78,17 @@ pub(crate) fn parse_id3v1(reader: [u8; 128]) -> Tag {
|
|||
|
||||
tag
|
||||
}
|
||||
|
||||
fn decode_text(key: ItemKey, data: &[u8]) -> Option<TagItem> {
|
||||
let read = data
|
||||
.iter()
|
||||
.filter(|c| **c > 0x1f)
|
||||
.map(|c| *c as char)
|
||||
.collect::<String>();
|
||||
|
||||
if read.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(TagItem::new(key, ItemValue::Text(read)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Probe {
|
|||
pub fn file_type_from_extension(&self, path: impl AsRef<Path>) -> Option<FileType> {
|
||||
if let Some(ext_os) = path.as_ref().extension() {
|
||||
if let Some(ext) = ext_os.to_str() {
|
||||
return FileType::try_from_ext(ext).ok();
|
||||
return FileType::try_from_ext(&*ext.to_lowercase()).ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ impl FileType {
|
|||
"opus" => Ok(Self::Opus),
|
||||
"flac" => Ok(Self::FLAC),
|
||||
"ogg" => Ok(Self::Vorbis),
|
||||
"m4a" | "m4b" | "m4p" | "m4v" | "isom" | "mp4" => Ok(Self::MP4),
|
||||
"mp4" | "m4a" | "m4b" | "m4p" | "m4r" | "m4v" | "3gp" => Ok(Self::MP4),
|
||||
"oga" => Err(LoftyError::Ogg(
|
||||
"Files with extension \"oga\" must have their type determined by content",
|
||||
)),
|
||||
|
|
Loading…
Reference in a new issue