Version 1.1.0 - Refactor + Intergration Backend

This commit is contained in:
2025-07-25 17:56:30 +02:00
parent a59d7a66db
commit 98cdae97c0
58 changed files with 244 additions and 70 deletions

View File

@@ -0,0 +1,31 @@
function isAudioFile(buffer) {
// Ensure the buffer is long enough to contain the magic number
if (!Buffer.isBuffer(buffer)) {
throw new TypeError('Expected a Buffer');
}
if (buffer.length < 2) {
return false;
}
// Convert the first few bytes to a hex string
const signature = buffer.subarray(0, 4).toString('hex').toUpperCase();
// Audio file signatures
const audioSignatures = [
'494433', // ID3 tag for MP3
'FFFB', // Another possible MP3 signature
'FFF3', // Another possible MP3 signature
'FFF2', // Another possible MP3 signature
'52494646', // RIFF header for WAV
'4F676753', // OGG container
'66747970', // MP4 container
// Add more audio file signatures as needed
];
// Check if the signature matches any known audio file type
return audioSignatures.some(magicNumber => signature.startsWith(magicNumber));
}
module.exports = {
isAudioFile
};