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

Add a list of extensions #509

Open
Serial-ATA opened this issue Feb 21, 2025 · 0 comments
Open

Add a list of extensions #509

Serial-ATA opened this issue Feb 21, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Serial-ATA
Copy link
Owner

Summary

A lot of projects that use Lofty are scanning directories and filtering files based on a set of extensions. What typically ends up happening is only a few popular extensions (mp3, flac, wav) will make it in the list, and not all of the formats that Lofty supports. Not to mention it's just a bunch of duplicated work.

FileType::from_ext has a pretty good list of extensions:

match ext.as_str() {
"aac" => Some(Self::Aac),
"ape" => Some(Self::Ape),
"aiff" | "aif" | "afc" | "aifc" => Some(Self::Aiff),
"mp3" | "mp2" | "mp1" => Some(Self::Mpeg),
"wav" | "wave" => Some(Self::Wav),
"wv" => Some(Self::WavPack),
"opus" => Some(Self::Opus),
"flac" => Some(Self::Flac),
"ogg" => Some(Self::Vorbis),
"mp4" | "m4a" | "m4b" | "m4p" | "m4r" | "m4v" | "3gp" => Some(Self::Mp4),
"mpc" | "mp+" | "mpp" => Some(Self::Mpc),
"spx" => Some(Self::Speex),
_ => None,
}
}

It too isn't perfect, of course. But if projects start using a list of extensions we provide, then they get any improvements to it for free.

API design

/// ...
/// NOTE: This is not an exhaustive list, blah blah blah
pub const EXTENSIONS: &[&str] = &["mp3", "flac", ...];
@Serial-ATA Serial-ATA added the enhancement New feature or request label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant