Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map tag ID3v2.2 TBP to common.bpm #977

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/common/MetadataCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class MetadataCollector implements INativeMetadataCollector {
this.common[tag.id].of = of != null ? of : this.common[tag.id].of;
return;

case 'bpm':
case 'year':
case 'originalyear':
tag.value = parseInt(tag.value, 10);
Expand Down
5 changes: 4 additions & 1 deletion lib/id3v2/ID3v22TagMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export const id3v22TagMap: INativeTagMap = {
TSC: 'composersort',
TSP: 'artistsort',
TST: 'titlesort',
WFD: 'podcasturl'
WFD: 'podcasturl',

TBP: 'bpm'

};

export class ID3v22TagMapper extends CaseInsensitiveTagMap {
Expand Down
Binary file added test/samples/mp3/Betty Lou.mp3
Binary file not shown.
17 changes: 17 additions & 0 deletions test/test-id3v2.2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ describe('ID3v2Parser', () => {
assert.strictEqual(pics[0].type, 'Cover (front)', 'picture type');
});

describe('Tag mapping', () => {

it("TBP (beats per minute)", async () => {

const filePath = path.join(samplePath, 'mp3', 'Betty Lou.mp3');

const {format, common, native} = await mm.parseFile(filePath, {duration: true});
assert.strictEqual(format.container, 'MPEG', 'format.container');
assert.strictEqual(format.codec, 'MPEG 1 Layer 3', 'format.codec');

assert.strictEqual(common.title, 'Betty Lou', 'common.title');
assert.strictEqual(common.artist, 'The Hub Caps', 'common.artist,');

assert.strictEqual(common.bpm, 177, 'common.bpm,');
});
});

});

describe('Post parse genre', () => {
Expand Down