Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should parse a raw ID3v2.3 header', () => {
const filePath = path.join(samplePath, 'MusicBrainz - Beth Hart - Sinner\'s Prayer.id3v23');
const metadata = new MetadataCollector({});
return strtok.fromFile(filePath).then(tokenizer => {
return new ID3v2Parser().parse(metadata, tokenizer, {}).then(() => {
assert.strictEqual(33, metadata.native['ID3v2.3'].length);
const id3v23 = mm.orderTags(metadata.native['ID3v2.3']);
assert.isDefined(id3v23.UFID, 'check if ID3v2.3-UFID is set');
});
});
});
export async function parseFile(filePath: string, options: IOptions = {}): Promise {
debug(`parseFile: ${filePath}`);
const fileTokenizer = await strtok3.fromFile(filePath);
const fileReader = new RandomFileReader(filePath, fileTokenizer.fileSize);
try {
await Core.scanAppendingHeaders(fileReader, options);
} finally {
fileReader.close();
}
try {
const parserName = ParserFactory.getParserIdForExtension(filePath);
if (!parserName)
debug(' Parser could not be determined by file extension');
return await ParserFactory.parse(fileTokenizer, parserName, options);
} finally {
await fileTokenizer.close();