Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getMeta = ({ fullPath, name }: TrackStats): ShallowTrackMeta => {
try {
const { artist, title, ...rest } = id3.read(fullPath);
if (!artist || !title) {
throw new Error('id3 tags dont have enough data');
}
return { artist, title, ...rest, origin: 'id3' };
}
catch (e) {
const [artist, title] = name.split(' - ');
return { artist, title, origin: 'fs' };
}
};