Files
otunes/lib/audio-content-type.ts
T

23 lines
530 B
TypeScript

export function audioContentTypeForPath(filePath: string): string {
const lower = filePath.toLowerCase()
if (lower.endsWith(".mp3")) {
return "audio/mpeg"
}
if (lower.endsWith(".m4a")) {
return "audio/mpeg"
}
if (lower.endsWith(".flac")) {
return "audio/flac"
}
if (lower.endsWith(".ogg") || lower.endsWith(".opus")) {
return "audio/ogg"
}
if (lower.endsWith(".wav")) {
return "audio/wav"
}
if (lower.endsWith(".aac")) {
return "audio/aac"
}
return "application/octet-stream"
}