Skip to content

Add a list of extensions #509

Open
Open
@Serial-ATA

Description

@Serial-ATA

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", ...];

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions